79. Problem to reverse all the numbers in a given list.  

In this Python list program, we will take a user input as a list and reverse all the numbers in a given list with the help of the below-given steps.

Reverse all the 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. Add the reverse number to the empty list.
  4. Print the list to see the result.
				
					#Input lists
list1 = [123, 145, 633, 654, 254]
reverse_list = []

#Calculating reverse number
for value in list1:
    reverse = 0
    while value != 0:
        digit = value%10
        reverse = reverse*10 + digit
        value //= 10
    reverse_list.append(reverse)

#Printing output
print(reverse_list)
				
			

Output :

				
					[321, 541, 336, 456, 452]
				
			

Related Articles

Get a list of Fibonacci numbers from 1 to 20

Print palindrome numbers from a given list

Leave a Comment