Python Program to print Palindrome numbers from the given list

In this, we have a rundown of numbers from that rundown we need to print just palindrome

numbers present in that rundown, palindrome numbers will be numbers, on turning around which number continues as before.

Initial barely any palindrome numbers are 0, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 11 , 22 , 33 , 44 , 55 , 66 , 77 , 88 , 99 , 101 , 111 , 121 , … etc.

Information group: Given a number n, size of rundown then next line contains space isolated n numbers.

Rationale: We will just change over the number into a string and afterwards utilizing reversed(string) predefined work in python, we will check whether the switched string is the same as the number or not.

Program

# Give size of list
n=int(input())

# Give list of numbers having size n
l=list(map(int,input().strip().split(' ')))

print("Palindrome numbers are:")
# check through the list to check 
# number is palindrome or not
for i in l:
    num=str(i)
    if("".join(reversed(num))==num):
        print(i)

Output

Python Program to print Palindrome numbers from the given list

Leave a Comment

error: Alert: Content is protected!!