what are filters in python

Solutions on MaxInterview for what are filters in python by the best coders in the world

showing results for - "what are filters in python"
Dudley
16 Nov 2018
1In simple words, the filter() method filters the given iterable 
2with the help of a function that tests
3each element in the iterable to be true or not.
4
5Filter Methods is simply a like comprarator class of c++ STL
6
7
8Code Explanation: 
9  # A simple tutorial to show the filter 
10# methods in python
11
12grades = ['A','B','C','F']
13
14def remove_fails(grades):
15    return grades!='F'
16
17print(list(filter(remove_fails,grades)))