Home »
Using the Python ‘filter()’ Function to Filter a List, with Examples
This article will cover the syntax and usage of the filter function. It will work for both Python 2 and Python 3. The filter function in Python takes an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items that can be looped over) and checks that each item matches a set of criteria, removing those that don’t match. It’s a fast and easy way to filter the values in a list or array. Syntax for Python filter() The filter() function does not need to be imported to … Read more