+ 3
What is the output of this code? And explain also
n = 123 result = 0 while (n>0): remainder = int(n % 10) result = result * 10 + remainder n = int(n / 10) print(result)
3 Answers
+ 2
Thats the code to reverse the number.
Output is 321
0
321
n = 123 result = 0 while (n>0): remainder = int(n % 10) result = result * 10 + remainder n = int(n / 10) print(result)