To find reverse of a number in python, you have to ask from user to enter a number and then reverse that number to print the reversed number as output as shown here in the program given below.
Following python program ask from user to enter a number to find and print reverse of the number:
# Python Program - Find Reverse of a Number while True: print("Enter 'x' for exit.") num = input("Enter any number: ") if num == 'x': break try: number = int(num) except ValueError: print("Please, enter a number...") else: rev = 0 while number > 0: rev = (rev*10) + number%10 number //= 10 print("Reverse of entered number =",rev)
Here is the sample run of the above python program to illustrate how to find and print reverse of any number:
You may also like to learn or practice the same program in other popular programming languages: