Articles → Python → Filter Function In PythonFilter Function In PythonIn this article, we will discuss the filter function in Python.Purpose The filter function filters the items from a collection based on certain conditions.Syntax filter(function, collection)Example Let us consider a scenario where we want to keep only even numbers and filter the rest of the elements out. So, the code will be: -mylist = [1,2,3,4,5] print(list(filter(lambda num: num %2==0,mylist)))Output Posted 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