We can reverse a number in Python using loop and arithmetic operators. In this program, we are getting number as input from the user and reversing that number.
Let’s see a simple Python example to reverse a given number.
1 2 3 4 5 6 7 8 9 10 11 12 |
# Python Program to Reverse a Number using While loop Number = int(input("Please Enter any Number: ")) Reverse = 0 while(Number > 0): Reminder = Number %10 Reverse = (Reverse *10) + Reminder Number = Number //10 print("\n Reverse of entered number is = %d" %Reverse) |