filter method filter out the iterable with the help of a given function and return the result in the form of a iter(list,set).
Basic Syntax :- filte(func,iter)
Example :-
a = [1,2,3,4,5]
c = list(filter(lambda x : x%2==0 ,a))
print(c)
It filter out the all those elements that are divisble by 2 from the above iterable a.
Hence the output will be [2,4]
Basic Syntax :- filte(func,iter)
Example :-
a = [1,2,3,4,5]
c = list(filter(lambda x : x%2==0 ,a))
print(c)
It filter out the all those elements that are divisble by 2 from the above iterable a.
Hence the output will be [2,4]
No comments:
Post a Comment