Discuss / Python / 23333虽然方法不好但还是实现了

23333虽然方法不好但还是实现了

Topic source

skysmine

#1 Created at ... [Delete] [Delete and Lock User]

-- coding: utf-8 --

def is_palindrome(n): m=str(n) q=0

for i in range(0,len(m)):
    q=int(m[i])*10**i+q      #把m反过来赋值给q
return int(m)-q==0           #判断他俩是否相等

output = filter(is_palindrome, range(1, 100000)) print(list(output))


  • 1

Reply