TypeError: 'str' object is not callable - Dictionaries

Screen Link: https://app.dataquest.io/m/314/dictionaries-and-frequency-tables/6/checking-for-membership

My Code:

is_in_dictionary_1 = '9+' in content_ratings
is_in_dictionary_2 = 987 in content_ratings

if '17+' in content_ratings:
    result = "It exists"

What I expected to happen:
“It exits”

What actually happened:

TypeErrorTraceback (most recent call last)
<ipython-input-1-821262a9ff61> in <module>()
      6 if '17+' in content_ratings:
      7     result = "It exists"
----> 8 print(result)

TypeError: 'str' object is not callable```

<!--Enter other details below: -->
Just don´t understand what is the error because dthe code is the same as the solution.....
1 Like

You probably assigned a string to a variable named print. When you do that, the function print is replaced by the string, and when you try to call it, you get an error. Even if you deleted the code, the variable is still stored in the memory.

Check this topic to see how to fix it:


Thank you for your explanation! It´s clear :slight_smile: