def lychrel(x): for i in xrange(50): t = x + int(str(x)[::-1]) if t == int(str(t)[::-1]): return False x = t return True count = 0 for i in xrange(1, 10000): if lychrel(i): count += 1 print count