maxiter = 10 n = input('Please enter a number: ') # keep n as a string throughout the program #TODO: verify that n represents a number for k in range(maxiter): if n == n[::-1]: print('This took', k, 'iterations.') break #n = int(n) + int(n[::-1]) n = str(int(n) + int(n[::-1])) print(n) else: print('Could not reach a palindrome :(')