80. Problem to print palindrome numbers from a list.  

In this program, we will take a user input as a list and get palindrome numbers from a given list.

Palindrome numbers in a list:

Steps to solve the program
  1. Take a list as input and create an empty list.
  2. Calculate the reverse of each number from the given list using for and while loop.
  3. Check if the original number and reversed numbers are equal or not.
  4. if equal then add those reverse number to the empty list.
  5. Print the list to see the result.
				
					#Input list
list1 = [121, 134, 354, 383, 892, 232]
list2 = []

for value in list1:
    num = value
    reverse=0
    while num != 0:
        digit = num%10
        reverse = reverse*10 + digit
        num //= 10
    if reverse == value:
            list2.append(value)

#Printing output
print(list2)
				
			

Output :

				
					[121, 383, 232]
				
			

Related Articles

Reverse all the numbers in a given list

Count the total number of vowels in a list

Leave a Comment