Python filter() Use of functions
def fn(n): # Define a function , It needs to write formal parameters
return n%2 == 0 # Write function judgment conditions
''' There is no need to write an excuse to call a function here fn().'''
l1 = list(filter(fn, range(23))) # interable True element in The formation of a filter object , Iteratable object ; Can pass list、tuple And so on to convert it to the desired format
print(l1) # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]