Answer to Question #80127 in Python for somnath khanra

Question #80127
Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.
1
Expert's answer
2018-08-27T04:44:10-0400
def intreverse(number:int) -> int:
return int(str(number)[::-1])

, where at the beginning function converts number to string, then uses string slice [::-1] which makes reverse of string and finally converts this string back to int

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS