Write a method, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value of reverseDigit(12345) is 54321. Also, write a program to test your method. Call this method and print the results.
N = 0
def reverseDigit(num):
global N
if (num > 0):
Reminder = num % 10
N = (N * 10) + Reminder
reverseDigit(num // 10)
return N
N = reverseDigit(12345)
print("Reverse of the number is: %d" % N)
Comments
Leave a comment