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. Retruns: 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.
- Python | Filter even values from a list
- Python | Pandas dataframe.filter()
- Lambda and filter in Python Examples
- Python | Pandas Series.filter()
- Python PIL | Image filter with ImageFilter module
- Python | Filter the negative values from given dictionary
- Python | Filter out integers from float numpy array
- Python lambda (Anonymous Functions) | filter, map, reduce
- Intersection of two arrays in Python ( Lambda expression and filter function )
- Python | Filter dictionary key based on the values in selective list
- Python | Filter list of strings based on the substring list
- Python | Filter a list based on the given list of strings
- Noise removal using Median filter in C++
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.
Improved By : kailashc_j