class Solution:
def isPalindrome(self, x: int):
if x<0:
return False
else:
y = str(x)[::-1]
if y == str(x):
return True
else:
return False
我自己写的另一种:
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
s1 = str(x)
s2 = s1[::-1]
if s1==s2:
return True
else:
return False