Answer to Question #297628 in Python for Michael

Question #297628

Reverse of a number using recursion in python


1
Expert's answer
2022-02-14T12:04:55-0500


reverseNumber = 0
def reverse(num):  
    global reverseNumber
    if (num > 0):  
        Reminder = num % 10  
        reverseNumber = (reverseNumber * 10) + Reminder  
        reverse(num // 10)  
    return reverseNumber




number=int(input("Input the number: "))
res = reverse(number);
print(f"Reverse of {number} is {res}.");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS