Computer Science

Given a list of integers, write a program to find those which are palindromes. For example, the number 4321234 is a palindrome as it reads the same from left to right and from right to left.

Python

Python Control Flow

9 Likes

Answer

print("Enter numbers:")
print("(Enter 'q' to stop)")

while True :
    n = input()
    if n == 'q' or n == 'Q' :
        break
    n = int(n)
    t = n
    r = 0
    while (t != 0) :
        d = t % 10
        r = r * 10 + d
        t = t // 10
    if (n == r) :
        print(n, "is a Palindrome Number")
    else :
        print(n, "is not a Palindrome Number")

Output

Enter numbers:
(Enter 'q' to stop)
67826
67826 is not a Palindrome Number
4321234
4321234 is a Palindrome Number
256894
256894 is not a Palindrome Number
122221
122221 is a Palindrome Number
q

Answered By

3 Likes


Related Questions