用來篩選一個可迭帶物件,回傳符合運算式的元素。
語法:filter(function, iterable)
filter(function, iterable)
a = [1, 2, 3, 4, 5] even = filter(lambda x: x % 2 == 0, a) # <filter object at 0x000001833AA71B88> print(list(even)) # [2, 4]