Articles → Python → Filter Function In PythonFilter Function In PythonIn this article, we will discuss filter function in python.Purpose Filter function filters the items from a collection based on certain condition.Syntax filter(function, collection)Example Let us consider a scenario where we want to keep only even numbers and filters rest of the element out. So, the code will bemylist = [1,2,3,4,5] print(list(filter(lambda num: num %2==0,mylist)))Here is the outputClick to EnlargePosted By - Karan Gupta Posted On - Wednesday, March 13, 2019 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
filter(function, collection)
mylist = [1,2,3,4,5] print(list(filter(lambda num: num %2==0,mylist)))
Query/Feedback