Answer to Question #80492 in Python for revanth
Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.
Here are some examples of how your function should work.
>>> intreverse(783)
387
>>> intreverse(242789)
987242
>>> intreverse(3)
3
1
2018-09-07T05:11:36-0400
Answer
def intreverse(number, res=0):
if number==0:
return res
else : res=(res*10)+number%10
return intreverse (number//10,res)
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
Python
Comments
Leave a comment