Skip to content

Commit fc15059

Browse files
authored
Merge pull request ephremdeme#48 from AnshMishra2001/master
python code to reverse a number
2 parents 261e694 + 785936d commit fc15059

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

problems/reverse.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Input number from the user
2+
N = int(input("Enter the number to be reversed "))
3+
4+
# Initiate value to null. R will store the value of the reverse of user input
5+
R = 0
6+
7+
# Check using while loop
8+
9+
while(N>0):
10+
#Logic
11+
remainder = N % 10
12+
R = (R * 10) + remainder
13+
N = N//10
14+
15+
# Print the output
16+
print("The reverse number is: {}".format(R))

problems/reversenumber.py

Whitespace-only changes.

0 commit comments

Comments
 (0)