Palindrome

, , Leave a comment

#!/usr/bin/python3

number = input('Enter number ')

step = 0
sum = 0

fwd = int(number)
rev = int(number[::-1])

if fwd == rev:
    print ('poly')
    sum = number
else:
    while fwd != rev:
        sum = fwd + rev
        fwd = str(sum)
        rev = int(fwd[::-1])
        fwd = int(fwd)
        step += 1

print (step)
print (sum)
 

Leave a Reply