TypeError: 'int' object is not callable in Python 3.8.2

Dung Do Tien Sep 05 2021 122

Hello you guys, I am a newbie in Python and I'm also studying more about Python.
I have a small assignment, I want to get weight and height numbers from user input and calculate the number of them. Like this:

weight = int(input("Enter the weight: "))
height = int(input("Enter the height: "))
number = weight(height + height)
print("Your number = ", number)

But I get an exception TypeError: 'int' object is not callable when I run the code above.

Enter the weight: 54
Enter the height: 156
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    number = weight(height + height)
TypeError: 'int' object is not callable

And I am using python 3.8.2

Anyone can explain it to me? How can I solve it?

Thanks for any response.

Have 1 answer(s) found.
  • B

    Blue Jame Sep 05 2021

    In the above code, we missed entering the arithmetic operator * in line 3 which lead to the error. Simply include this operator to avoid the error.

    For example:

    weight = int(input("Enter the weight: "))
    height = int(input("Enter the height: "))
    number = weight(height + height)
    print("Your number = ", number)

    #Output

    Enter the weight: 67
    Enter the height: 167
    Your number =  22378

    hope it solve the problem for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close