Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # How do I debug this code of the 'TypeError: 'int' object is not callable' error in Python?

• 0
• 0
• 0
• 7
• 0
• 0
• 0
• 4.84k

Hey guys! I want to write a program that finds the sum of cubed terms. i.e. 1**3 + 2**3 + n**3
I wrote down the following code:

``````// n = input('Give the value of n.')
n = int (n)
s = ((n(n+1))/2)**2
print ('Sum equals =', s)
The output I got:

raceback (most recent call last):
File "/Users/apple/Documents/tryin.py", line 15, in <module>
s = ((n(n+1))/2)**2
``````

TypeError: 'int' object is not callable

>>>
I Would really appreciate some help guys.
:D
And any suggestions on what to practice to be better at coding and stop getting these errors will be of help.
:)
Thanks!

Use this code and resolve your problem int object is not callable.
n = input('Give the value of n.')
n = int (n)
s = (((n+1))/2)**2
print ('Sum equals =', s)

n=raw_input("enter the valude of n")
n=int(n)
s = ((n*(n+1))/2)**2
print s

Just add a multiply sign there next to n and it will start working. (It doesnt work how we write on a paper )

This particular error aside, I think what you really want is:

```sum( [i**3 for i in range(n+1)] )
```

when you get a error like that: "type integer is not callable", it's prabbly a syntax error / typo:

the syntax for calling a function in Python is to put parens after it:

fun()

so look and see if you have put parens after something that is not a function -- and indeed you have:

(note this UI sucks! I have to write this in a modal dialog, so I can't see the original question!)

I think you have code like:

n(1 + n)

look for the n(...) -- that is math notation for multiply, but it's python notation for call the function "n" -- it should be:

n * (1 + n)

You have to redefined your "sum" function to be an integer data type. So it is rightly telling you that an integer is not something you can pass a range.To fix this, restart your interpreter.Then all is okay.like this n = input('Give the value of n.') n = int (n) s = (((n+1))/2)**2 print ('Sum equals =', s)

use this and solve the type error : int object in not callable n = input('Give the value of n.') n = int (n) s = (((n+1))/2)**2 print ('Sum equals =', s)

You have to redefined your "sum" function to be an integer data type. So it is rightly telling you that an integer is not something you can pass a range.To fix this, restart your interpreter.Then all is okay

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...