Home > Enterprise >  CMD Python TypeError: 'int' object is not callable
CMD Python TypeError: 'int' object is not callable

Time:06-06

its my first day programming in this lenguage. Sorry for my english XD

Code:

age = input("insert your age: ")
new_age = int(age)   5
print(new_age)

cmd:

insert your age: 
    Traceback (most recent call last):
      File ("my File route"), line 11, in <module>
        new_age = int(age)   5
    TypeError: 'int' object is not callable

CodePudding user response:

The code shown in the question will not give that error. You probably have more code in that file where you have created a variable called int - e.g., int = 99 If you do that you shadow/override the int function which will lead to the error shown

CodePudding user response:

I find nothing wrong with it, but im not familiar with python. I tested your ccode in a online compiler and I got no syntax error. Could it be that you enter something wrong in the console, when asked for input, you just need to enter a number. However i am not sure, why you defined a new variable here. You could just do it like this:

# Online Python - IDE, Editor, Compiler, Interpreter
age = input("insert your age: ")
age = int(age)   5
print(age)

This way you just change the old age variable and add 5 to her. If you get an error i expect you handled something wrong in a console or a file where yout put the code.

  • Related