Skip to content
Sign upLog in
← Back to Community

How to fix type error in python?

Profile icon
727Nerd

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 [earned 5 cycles]
View Answer
Voters
Profile icon
nikos1667
Profile icon
JuliaBinns
Profile icon
727Nerd
Comments
hotnewtop
Profile icon
CodeLongAndPros

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

Profile icon
SixBeeps

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

Profile icon
727Nerd

@SixBeeps
Thanks

Profile icon
PYer

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!