Python Program to reverse a number using function
In this program, You will learn how to reverse a number using function in Python.
def reverse(n):
#Statement
#logic start here
Example: How to reverse a number using function in Python
def reverse(n):
rev = 0
while n > 0:
r = n % 10
rev = rev * 10 + r
n = int(n / 10)
return rev
x = int(input("Enter a number:"))
result = reverse(x)
print("Reverse is:", result)
Output:
Enter a number:123
Reverse is: 321