- filter() is a python function which filters the given sequence with the help of a function that tests each element in the sequence to be true or not.
-It works on the return value by the function, if function return True then filter consider that element otherwise discard.
we have a function which return True on even number false on odd number
list is [1,2,3,4]
filter(function,l) will return [2,4]
print("List after filtering")
print("After even filteration, list become")
list is [1, 2, 3, 4, 'one', 'two', 1.2]
List after filtering
[1, 2, 3, 4]
After even filteration, list become
-In this program, we have a list [1, 2, 3, 4, 'one', 'two', 1.2] , then firstly we filter all integer value by filter(func,l) func() function return True on integer value, then we have a list [1,2,3,4] then we filter all even element from the list by filter(geteven,l), where geteven return True on even values.