Filter Function in Python


Creates a list of elements for which a function returns true.

Source Code

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