class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        if x<0:
            return False
        elif x<10:
            return True
        elif x%10==0:
            return False
        revx=0
        tmpx=x
        while tmpx>0:
            revx=revx*10+tmpx%10
            tmpx//=10
        return revx==x

class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        if x < 0:
            return False
        elif x < 10:
            return True
        elif x % 10 == 0:
            return False
        revx = 0
        tmpx = x
        while tmpx > 0:
            revx = revx * 10 + tmpx % 10
            tmpx //= 10
        return revx == x

a = Solution()
print(a.isPalindrome(-1) == False)
print(a.isPalindrome(1) == True)
print(a.isPalindrome(121) == True)
print(a.isPalindrome(1221) == True)
print(a.isPalindrome(10021) == False)

Revise 009, add test cases
Revise 009, add test cases

  class Solution(object):
      def isPalindrome(self, x):
          """
          :type x: int
          :rtype: bool
          """
-         if x<0:
+         if x < 0:
              return False
-         elif x<10:
+         elif x < 10:
              return True
-         elif x%10==0:
+         elif x % 10 == 0:
              return False
-         revx=0
+         revx = 0
-         tmpx=x
+         tmpx = x
-         while tmpx>0:
+         while tmpx > 0:
-             revx=revx*10+tmpx%10
+             revx = revx * 10 + tmpx % 10
-             tmpx//=10
+             tmpx //= 10
-         return revx==x
+         return revx == x
  
+ a = Solution()
+ print(a.isPalindrome(-1) == False)
+ print(a.isPalindrome(1) == True)
+ print(a.isPalindrome(121) == True)
+ print(a.isPalindrome(1221) == True)
+ print(a.isPalindrome(10021) == False)
+ 
Revise 009, add test cases
## Code Before:
class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        if x<0:
            return False
        elif x<10:
            return True
        elif x%10==0:
            return False
        revx=0
        tmpx=x
        while tmpx>0:
            revx=revx*10+tmpx%10
            tmpx//=10
        return revx==x

## Instruction:
Revise 009, add test cases
## Code After:
class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        if x < 0:
            return False
        elif x < 10:
            return True
        elif x % 10 == 0:
            return False
        revx = 0
        tmpx = x
        while tmpx > 0:
            revx = revx * 10 + tmpx % 10
            tmpx //= 10
        return revx == x

a = Solution()
print(a.isPalindrome(-1) == False)
print(a.isPalindrome(1) == True)
print(a.isPalindrome(121) == True)
print(a.isPalindrome(1221) == True)
print(a.isPalindrome(10021) == False)
