Programming Examples

Python recursive function to print the reverse of number


Write a recursive function to print the reverse of given number.

Solution:

def reverse(num):
    if num<10:
        print(num)
    else:
        print(num%10,end='')
        reverse(num//10)
n=int(input("Enter any Number : "))
reverse(n)
Output

Enter any Number : 576

675

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad