reverse of the number in python by R4R Team

Example -

let we have a number like-
a=1234

our aim is to print above number in reverse order like a=4321

program -

print("Enter any number")
n=int(input())
print("Original number -",end="")
print(n)
ans=0
while(n):
t=n%10
ans=ans*10+t
n=int(n/10)

print("Number in reverse order ",end=" ")
print(ans)

output -

Enter any number
1234
Original number -1234
Number in reverse order 4321


- In this program, we take a input of a number and print the reverse of it, mainly the body of while loop is the main code of doing this.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!