用python判断一个数是否为回文数

a = input(“please input a number:”)

b = len(a)
i = 0
j = 0

if b%2 != 0:
for i in range(int((b - 1) / 2)):
if a[i] != a[b - i - 1]:
print(“this is not palindrome!”)
j = 1
break

else:
for i in range(int(b/2)):
if a[i] != a[b-i-1]:
print(“this ia s palindrome!”)
j = 1
break

if j != 1:
print(“this is a palindrome!”)

你可能感兴趣的:(用python判断一个数是否为回文数)