Discuss / Python / 练习题

练习题

Topic source

唯情恋昉

#1 Created at ... [Delete] [Delete and Lock User]
# 请用匿名函数改造下面的代码
def is_odd(n):
    return n % 2 == 1

L = list(filter(is_odd, range(1, 20)))
print('L =', L)

# ----------------------------------------------------

L2 = list(filter(lambda n: n % 2 == 1, range(1, 20)))
print('L2 =', L2)

  • 1

Reply