0

I am unable convert int to string using str(). Everywhere on internet I found str() used to convert int to string.

I tried to run this on jupyter notebook

My Code:

num=23
string=str(num)

Error:

TypeError Traceback (most recent call last)
ipython-input-24-63bcf2e7ab44> in <module>
 1 num=23
 ----> 2 string=str(num)
TypeError: 'str' object is not callable
asked Oct 18, 2019 at 21:15
3
  • 4
    Do you have a variable in your code named str? Commented Oct 18, 2019 at 21:16
  • 1
    yes I found variable name str. Commented Oct 18, 2019 at 21:18
  • 2
    str is a global built-in, so if it's redefined anywhere, you're overwriting that. Commented Oct 18, 2019 at 21:18

1 Answer 1

4

Somewhere earlier on, you did:

str = 'somestr goes here'

Never name a variable str; it causes this problem. You can correct it for now with:

del str

but the solution in the future is to never use str as a variable name.

answered Oct 18, 2019 at 21:17
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.