Possible Duplicate:
Why does 'return self' return None?
I've been trying to solve Problem 55 on Project Euler (http://projecteuler.net/problem=55) and now that I think I have the answer, I Experience a problem. I don't want a solution to the Problem 55, just on what I've done wrong.
Here's my code: (I don't think you need all of it)
t=0
lychrel=0
called=0
def iteratepal(n):
global t
global called
called+=1
b = int(''.join(reversed(str(n))))
#print ("n =",n,"\nb =",b,"\nb+n =",b+n,"\n")
if ispal(b+n) or ispal(n):
t=0
return False
if t<50:
t+=1
iteratepal(b+n)
else: # Here's the prob
t=0 # this block is executed (because it prints "yea")
print("yea") # but it doesn't return True!
return True # you can try it yourself (even in the interpreter)
def ispal(n):
if n == int(''.join(reversed(str(n)))):
return True
return False
print(iteratepal(196))
for i in range(0,200):
if iteratepal(i)==True:
lychrel+=1
print(i,"is Lychrel!")
else:
print(i,"is not a Lychrel!")
print(lychrel)
Thanks for any help, I'm really confused with this.