From the course: Functional Programming with Python

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Filtering

Filtering - Python Tutorial

From the course: Functional Programming with Python

Start my 1-month free trial

Filtering

- [Instructor] The next important built in list function in Python is called Filter. Now Filter is used when you want to find all of the elements in a list or some other type of iterable that fit some type of criteria. For example, if we have a list of numbers and we want to get all the numbers from it that are even or if we have a list of employee data and we want to find the employees from this list that make more than a certain amount per year these are things that Filter can helps us with. The syntax of Filter is very similar to map. We call it by passing it both a function and an iterable such as a list, tuple or set. The main difference between filter and map, however, is the purpose of the function that we pass into it. In map we pass in a function that returns a value for each element in an array. The return value of this function represents what that element becomes in our new array. On the other hand though, for…

Contents