[Python programming 300 examples] Example 1 Reverse a 3-digit integer

# coding: utf-8
class Solution(object):
    def reverse_num(self, num):
        hundreds = num/100
        tens = num % 100/10
        ones = num % 10
        return ones*100 + tens*10 + hundreds


if __name__ == '__main__':
    solution = Solution()
    num = solution.reverseNum(800)
    print (num)

Guess you like

Origin blog.csdn.net/weixin_45329445/article/details/116035349