The filter() Function for Filtering Data in Python


Filter items out of an iterable.

Source Code

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