Discuss / Python / daan

0泡老醋

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

def is_palindrome(n): if n<0 | n-int(n)!=0: return False L = [] while n/10 >= 0.1: L.append(n % 10) n = int(n/10) i = len(L) if(i == 1): return True else: for j in range(0,int(i/2)): if L[j] != L[i-j-1]: return False return True

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


  • 1

Reply