The filter() Function for Filtering Iterables in Python


Filter items out of an iterable.

Source Code

numbers = [1, 2, 3, 4, 5, 6]
even = filter(lambda x: x % 2 == 0, numbers)
print(list(even))
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments