oneabdi
oneabdi

Reputation: 57

TypeError 'str' object is not callable in Python

The command prompt says TypeError: 'str' object is not callable. It highlights these two separate lines of code.

height = float(input('Please enter your height input meters(decimals): '))

height = int(input('Please enter your height input inputches(whole number: '))

Upvotes: 0

Views: 753

Answers (1)

user2555451
user2555451

Reputation:

Now you see why you should never name a variable after a built-in. ;)

You said yourself that you made a variable named input elsewhere in the code. Judging by your error, you must have done this before those two lines. Also, you must have made this variable hold a string.

By doing this, you overshadowed the built-in input. This means that, when you get to those two lines, input no longer exists as the built-in. Instead, it is a string.

Finally, placing (...) after input throws an error because you can't call a string like a function.

Summed up, you can fix the problem by simply picking a different name for that variable besides input.

Upvotes: 6

Related Questions