AI engineering glossary · Python core
What is filter?
filter: A built-in function that keeps only the items of an iterable for which a given function returns a true value, returning a lazy iterator. It is an alternative to a comprehension with an if.
filter: an example
list(filter(lambda n: n > 2, [1, 3, 5])) gives [3, 5].
Related terms
More Python core terms
Where you learn it
filter is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.