Answers for "Write a Python program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure."

0

Write a Python program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure.

i = int(input("enter a number"))


flip = 0
def rev(x):
    reverse = 0
    while x>0:
        last = x%10
        reverse= (reverse*10)+last
        x = x//10
    return(reverse)
 
num = i
while(1):
    
    flip = rev(num)
    if flip == num:
        print("you got a palindrome dude %d into %d "%(i,num))
        break
    else:
        num = num+flip
Posted by: Guest on September-09-2021

Code answers related to "Write a Python program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure."

Code answers related to "TypeScript"

Browse Popular Code Answers by Language