filter()¶
Description¶
With filter() you can apply a conditional expression to a list and only keep elements where the filter return true.
Also see find(), which returns only the first matching element rather than all of them.
Example¶
This filters out all the true values in the list evaluating to [false].
This removes elements smaller or equal to 2 from the list evaluating to [4, 3, 4].