9.Palindrome Number

 

 

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

 

posted @ 2020-05-09 14:27  星海寻梦233  阅读(83)  评论(0编辑  收藏  举报