Article From:https://www.cnblogs.com/lijinghuabj/p/9216208.html
class Solution():
    # @return a boolean
    def isPalindrome(self, x):
        if x < 0:
            return False
        div = 1
        while x/div >= 10:
            div = div * 10
            
        while x:
            left = int( x / div)
            right = int(x % 10)
            
            if left != right:
                return False
            
            x = int(( x % div ) / 10)
            div = div / 100
        return True
        
s = Solution()
print (s.isPalindrome(12321))

 

Leave a Reply

Your email address will not be published. Required fields are marked *