Python Program to Reverse a Given Number
In this example, we will write a simple program to take input number from the user and display it in a reverse way. To better understand this example, make sure you have knowledge of the following tutorials:-
Python Program to Reverse a Given Number
number = int(input("Enter the number to reverse: ")) reverse = 0 while number > 0: dig = number % 10 reverse = reverse * 10 + dig number //= 10 print("The Reverse of the number:", reverse)
The output of the above program is:-
Enter the number to reverse: 12345
The reverse of the number: 54321
The reverse of the number: 54321