009_Palindrome_Number.py in python 3
peterhuang1kimo opened this issue · 0 comments
peterhuang1kimo commented
I tried to run this code in python 3, and the result is not correct.
since the default number structure is float in python 3, I changed the code as bellow:
`class Solution(object):
def isPalindrome(self, x):
if x < 0:
return False
ls = len(str(x))
tmp = x
print((int(ls/2)))
for i in range(int(ls/2)):
right = int(tmp % 10)
left = tmp / (10 ** (ls - 2 * i - 1))
left = int(left % 10)
print (left, right)
if left != right:
return False
tmp = tmp // 10
return True
if name == 'main':
# begin
s = Solution()
print (s.isPalindrome(10000100001))`
Thank you.