Sujay_K
Sujay_K

Reputation: 163

Why do i get this error "TypeError: 'int' object is not callable"?

def diameter(Points):
    '''Given a list of 2d points, returns the pair that's farthest apart.'''
    diam,pair = max([((p[0]-q[0])**2 + (p[1]-q[1])**2, (p,q))
                     for p,q in rotatingCalipers(Points)])
    return pair


n=int(input())

a=[]

max=0

for i in xrange(n):
    m,n=map(int,raw_input().split())
    a.append((m,n))
    diameter(a)

Traceback

Traceback (most recent call last):
  File "geocheat1.py", line 56, in <module>
    diameter(a)
  File "geocheat1.py", line 43, in diameter
    for p,q in rotatingCalipers(Points)])
TypeError: 'int' object is not callable

Upvotes: 0

Views: 708

Answers (1)

Rahul K P
Rahul K P

Reputation: 16081

From the Traceback it's clear than you are trying to call int object, So rotatingCalipers may be declared as integer in your code.

See this example you will understand the error,

In [1]: a = (1,2,3)
In [2]: list(a)
Out[1]: [1, 2, 3]
In [3]: list = 5
In [4]: list(a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-61edcfee5862> in <module>()
----> 1 list(a)

TypeError: 'int' object is not callable

Upvotes: 1

Related Questions