Python Forum
TypeError: 'int' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'int' object is not callable
#1
Hello everybody, I just wrote this code to calculate Factorial using python 3.6 on Microsoft azure jupyter notebook. it's works fine for the first time, but when I re-run the cell. I got the bellow error. could you please help me.
number = int (input("please enter the number\n"))
if number == 0:
    print ("0! is 1")
    
elif number < 0:
    print ("Shoud NOT be negative number")

else:
    input = number
    factorial = 1
    while number > 0:
        factorial = factorial * number
        number -= 1 
        if number == 1:
            break
    print ("The factorial of ", input, "is ", factorial)
After I runing the code again I got this error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-aa8ffda27c1d> in <module>
----> 1 number = int (input("please enter the number\n"))
      2 if number == 0:
      3     print ("0! is 1")
      4 
      5 elif number < 0:

TypeError: 'int' object is not callable
Reply
#2
(Aug-29-2019, 09:52 AM)hakan Wrote: when I re-run the cell. I got the bellow error.
on line 9 you assign number to input, thus override the built-in function input().
Never use built-in functions, modules, packages, etc. as variable names. Fix this on line 9
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Aug-29-2019, 10:00 AM)buran Wrote: Never use built-in functions, modules, packages, etc. as variable names. Fix this on line 9
Many Thanks buran
Reply
#4
Many Thanks maram
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 270 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 449 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 679 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 920 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,262 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 777 Jul-23-2023, 02:25 PM
Last Post: Fare
  TypeError: 'float' object is not callable #1 isdito2001 1 1,046 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  TypeError: a bytes-like object is required ZeroX 13 3,838 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  'SSHClient' object is not callable 3lnyn0 1 1,125 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,373 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020