LeetCode 9、判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。

class Solution:
    def isPalindrome(self, x: int) -> bool:
        a = x
        if a<0:
            return False
        else:
            num = 0
            while(a!=0):
                temp = a%10
                a = a//10
                num = num*10+temp
            if num==x:
                return True
            else:
                return False

 

posted @ 2020-02-14 14:29  Halo辉Go  阅读(405)  评论(0编辑  收藏  举报