Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (18.4k points)
retagged by

The below code is giving me an error?

>>> variable = str(21)

Traceback (most recent call last):

  File "<pyshell#101>", line 1, in <module>

    variable = str(21)

TypeError: 'str' object is not callable

1 Answer

0 votes
by (36.8k points)
edited by

That code alone does not give you the error. For example:

~ $ python3.2

>>> variable = str(21)

>>> variable

'21'

Somewhere in your code, you have defined the str = something else, hiding the built-in definition of str. So you need to remove it, then your code will work fine.

Want to gain end-to-end skills in Data Science with Python? Enroll today in this Data Science with Python Course and be a master in it

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...