自己想了一个办法。不过如果用[::-1]确实很方便
# -*- coding: utf-8 -*- def is_palindrome(n): t = list(str(n)) t.reverse() return str(n) == ''.join(t) output = filter(is_palindrome, range(1, 1000)) print(list(output))
Sign in to make a reply
越聊越hi
自己想了一个办法。不过如果用[::-1]确实很方便