0

Can anybody tell me how can i avoid the overflow of this program?

from math import sqrt

f=lambda n: sum([int(i)*int(i) for i in str(n)])

L=[]

for n in range(0,10**20):

if sqrt(f(n))%1==0:# == float(int(sqrt(f(n)))):

L.append(n)

L.sort()

print "Número de quadrados perfeitos na lista:",len(L)

print L

y= lambda L: reduce(lambda x,y: x+y,L)

print y(L)