Ask coding questions

← Back to all posts
How to fix type error in python?
rian2008 (3)

A part of my code is: def TcKTcKTcK():

print(TcK)
TcKTcKTcK = input("Say yes")

if TcKTcKTcK == "yes":
print("Congratulations! You followed my instruction!")

if TcKTcKTcK == "Yes":
print("Congratulations! You followed my instruction!")

if TcKTcKTcK != "yes" and TcKTcKTcK != "Yes":
print("You failed to follow my instruction!")
print("Try again!")
TcKTcKTcK()

TcKTcKTcK()

and, when someone said no the result was...
TypeError: 'str' object is not callable.

My question is how do I fix this?

By the way, TcK is a variable from previous questions in this code.

Answered by CodeLongAndPros (1591) [earned 5 cycles]
View Answer
Comments
hotnewtop
CodeLongAndPros (1591)

You are saying:
TcKTckTck is a function
TcKTckTck is now a string
Use TcKTckTck as a function, although it is a string.

SixBeeps (5062)

TcKTcKTcK is a variable, not a method, so you can't put () next to it.

PYer (3771)

Could you link a repl rather than the code? Or put the code in a code block? This will make it easier to read and test. Thank You!