filter函数:过滤序列

def is_odd(n):
    return n % 2 == 1
 
newlist = filter(is_odd, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

for w in newlist:
    print(w)

filter

你可能感兴趣的:(python)