Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Filter Iterables With Python (Summary)

Python’s filter() allows you to perform filtering operations on iterables. This kind of operation consists of applying a Boolean function to the items in an iterable and keeping only those values for which the function returns a true result. In general, you can use filter() to process existing iterables and produce new iterables containing the values that you currently need.

In this video course, you learned how to:

  • Work with Python’s filter()
  • Use filter() to process iterables and keep the values you need
  • Combine filter() with map() and reduce() to approach different problems
  • Replace filter() with list comprehensions and generator expressions

With this new knowledge, you can now use filter() in your code to give it a functional style. You can also switch to a more Pythonic style and replace filter() with list comprehensions or generator expressions.

For further investigation, check out:

Download

Sample Code (.zip)

4.9 KB
Download

Course Slides (.pdf)

5.6 MB
Avatar image for Marco Perez

Marco Perez on July 9, 2023

Very very cool. This demystified what was heretofore obscure and scary functions (filter, map, reduce) and syntax (lambdas).

Looking forward to using these lots!

Avatar image for Negar Vahid

Negar Vahid RP Team on July 11, 2023

@Marco Perez I’m happy that filter, map, reduce and lambdas are not scary anymore! Hope you have fun using them in your future projects. Happy Pythoning!

Become a Member to join the conversation.