Reverse a Number
Easy 20 XPMathLoops
Commonly asked at TCS, Zoho
Read a non-negative integer and print it with its digits reversed. Leading zeros in the result are dropped (e.g. 1200 becomes 21).
- Input
- One non-negative integer n.
- Output
- The reversed number.
Sample 1
Input
12345
Output
54321
Sample 2
Input
1200
Output
21
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.