Discuss / Python / 交作业

交作业

Topic source

越聊越hi

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

自己想了一个办法。不过如果用[::-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))

  • 1

Reply