[Tutor] TypeError: 'int' object is not callable

Emile van Sebille emile at fenx.com
Wed May 16 22:43:55 CEST 2012


On 5/16/2012 1:17 PM Greg Christian said...
> def factors(n):
>      L = []
>      for i in range(1, int(n ** 0.5) + 1):
>          if (n % i == 0):
>              L.append(i)
>      return L

... now you've completed defining the function factors...

> def main():
>      factors = 0

... and here you create an integer of the same name...

>      counter = 0
>      L = []
>      while len(L) < 50:
>          counter += 1
>          L.append(counter)
>          Tn = sum(L)
>          x = factors(Tn)

... and here you attempt to call the interger factors passing it the 
argument Tn

>          #print x
>      print(sum(L))


Also, in the future please post the complete traceback  -- it relly helps.

Emile



More information about the Tutor mailing list