TypeError: 'int' object is not callable 'in Python 3.2?

advertisements

This question already has an answer here:

  • TypeError: 'int' object is not callable 4 answers

so i'm coding a tic tac toe game in python 3.2 and i have spent night and day trying to fix this and going over my code, script, or whatever you want to call it, so many times and still can't find it. i've googled it and all the answers are all to confusing or the person is scripting something way different from my tic tac toe game. and please beware, i'm just a beginner at python. when i try and run it an error comes up:

Traceback (most recent call last):
  File "/Users/user/Desktop/tic tac toe game.py", line 41, in <module>
    input = input("Select a spot:")
TypeError: 'int' object is not callable"

what does that mean? here's the code it says it's having a problem with:

while True:

    input = input("Select a spot:")
    input = int(input)

if you could help me, that would mean so much. it's been so annoying and i've been trying my hardest to fix it.


input() is a Python function, and you are using it both as the function and an identifier.

Using input as a variable name will work the first time, but the 2nd time through the loop there won't be an input() function any longer as that name now is associated with an integer variable.

So instead of function input() you just have a variable named input, hence the error (also as mentioned by @poke and @DSM in the comments)

Using answer as your variable name would be a better idea:

while True:
    answer = input("Select a spot:")
    answer = int(answer)