[Tutor] TypeError: 'int' object is not callable
Greg Christian
glchristian at comcast.net
Wed May 16 22:17:55 CEST 2012
Can anyone tell me what I am doing wrong here. When trying to call the factors function from main with x = factors(Tn), getting the error message: “TypeError: 'int' object is not callable”? Any help would be appreciated. Thanks.
def factors(n):
L = []
for i in range(1, int(n ** 0.5) + 1):
if (n % i == 0):
L.append(i)
return L
def main():
factors = 0
counter = 0
L = []
while len(L) < 50:
counter += 1
L.append(counter)
Tn = sum(L)
x = factors(Tn)
#print x
print(sum(L))
if __name__ == '__main__':
main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120516/fae31bf5/attachment.html>
More information about the Tutor
mailing list