Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n. (In python 3).Here are some examples of how your function should work.
>>> intreverse(783)
387
>>> intreverse(242789)
987242
>>> intreverse(3)
3
Answers
Answered by
6
Here are some examples of how your function should work. >>> intreverse(783) 387 >>> intreverse(242789) 987242 >>> intreverse(3) 3.
Answered by
0
In python 3,
//function definition
def intreverse(n):
rev=0
while ( n > 0 ):
last = n % 10
rev = rev * 10 + last
n = n / 10
return rev
Sample I/O:
intreverse(369)
963
Similar questions