Python filter() Function
The filter() function returns an iterator were the items are
filtered through a function to test if the item is accepted or not.
Syntax
filter(function, iterable)
Parameters
| Parameter | Description |
|---|---|
function |
Required. A Function to be run for each item in the iterable |
iterable |
Required. The iterable to be filtered |
Return Value
A filter object (which is an iterator).
Example
Using the filter() function:
Output
Click Run to execute your code
Enjoying these tutorials?