Discuss / Python / 表示思路来自于上一节作业反转字符串的L[::-1]

表示思路来自于上一节作业反转字符串的L[::-1]

Topic source

-李铁蛋_

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-
def is_palindrome(n):
    t = str(n)
    return lambda t: t == t[::-1]
# 测试:
output = filter(is_palindrome, range(1, 1000))
print(list(output))

-李铁蛋_

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

多写了一个lambda。。。正确为下:

def is_palindrome(n):
    t = str(n)
    return  t == t[::-1]

  • 1

Reply