Discuss / Python / 比较复杂的写法。

比较复杂的写法。

Topic source

霁天13

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

def is_palindrome(n): s = str(n) i = 0 while i < (len(s) - 1) / 2: if s[i] != s[len(s) - i - 1]: return False i = i + 1 return True

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


  • 1

Reply