TypeError: 'str' object is not callable
What it means
You put round brackets after something that is a string, so Python tried to call it like a function. Usually a variable has taken the name of a function, such as str or one of your own, or () was used where [] was meant.
1. A variable named `str`
This raises the error
Traceback (most recent call last): File "<exec>", line 3, in <module> TypeError: 'str' object is not callable
The fix
Score: 42
Naming a variable str hides the built-in str() function for the rest of the program. The same happens with input, len, max, sum and list. Pick a different name.
2. Reusing a function's name for its result
This raises the error
Traceback (most recent call last): File "<exec>", line 5, in <module> TypeError: 'str' object is not callable
The fix
Monthly report
After title = title(), the name title holds the string, not the function. A separate name for the result keeps the function callable.
3. Round brackets instead of square brackets
This raises the error
Traceback (most recent call last): File "<exec>", line 2, in <module> TypeError: 'str' object is not callable
The fix
p
Square brackets pick a character out of a string. Round brackets mean "call this", and a string cannot be called.
When you see this error, check
- Search your code for
str =,input =,len =and similar names, and rename them. - In this editor, variables stay in memory between runs. After renaming, choose Restart Python in the More menu so the old
stris gone. - Use
[]to pick a character from a string,()only to call a function. - Check for a missing operator between a string and brackets, such as
"Total" (5).
Related errors
All Python errors · How to read a traceback · Step through your code