Web Analytics

Python filter() Function

Built-in Function β€’ Functional

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

Related Functions