The filter() method filters the given sequence with the help of a function that tests each element in the sequence to be true or not.
filter(function, sequence) Parameters: function: function that tests if each element of a sequence true or not. sequence: sequence which needs to be filtered, it can be sets, lists, tuples, or containers of any iterators. Returns: returns an iterator that is already filtered.
The filtered letters are: e e
It is normally used with Lambda functions to separate list, tuple, or sets.
[1, 3, 5, 13] [0, 2, 8]
Please refer Python Lambda functions for more details.
- Spatial Filters - Averaging filter and Median filter in Image Processing
- Python - Filter key's value from other key
- Python | Pandas dataframe.filter()
- Python | Pandas Series.filter()
- Python - Filter Key from Nested item
- Lambda and filter in Python Examples
- Python | Filter even values from a list
- Python - Filter Non-None dictionary Keys
- Python - Filter above Threshold size Strings
- Python PIL | Image filter with ImageFilter module
- Python - Filter Range Length Tuples
- Python | Unique dictionary filter in list
- Python | Filter Tuple Dictionary Keys
- Python | Filter dictionary of tuples by condition
- Python - Filter index similar values
- Python - Filter and Double keys greater than K
- Python | Filter the negative values from given dictionary
- Create a vignette filter using Python - OpenCV
- Python - Filter odd elements from value lists in dictionary
- Python - Filter unequal elements of two lists corresponding same index
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.