Loading...
Loading...
Loading...
A report tool needs to show an account number backwards. Given a number n, print the number made by reading its digits from the end. Because the result is a number, leading zeros disappear: reversing 1200 gives 21.
Example 1
Input
1234
Output
4321
Digits 4, 3, 2, 1.
Example 2
Input
1200
Output
21
The zeros end up at the front and vanish.
Try the problem first. Open one hint at a time.
Build the answer step by step: move the old answer one place to the left, then add the new digit.
Moving left means multiplying by 10. The last digit of n is n % 10.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor