class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
y=list(str(x))
l=len(y)
sign=1
for i in range(l):
if cmp(y[i],y[l-i-1]):
sign=0
if sign==1:
return str(x)+" is a palindrome number!"
else:
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
y=list(str(x))
l=len(y)
sign=1
for i in range(l):
if cmp(y[i],y[l-i-1]):
sign=0
if sign==1:
return str(x)+" is a palindrome number!"
else:
return 'false'
在pycharm运行是正确的,在leetcode上输出不对,暂时不知道怎么解决。
注:cmp(x,y)函数:x>y,返回1;x<y,返回-1;x==y,返回0.