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:

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

Unlock This Lesson

Already a member? Sign-In

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

Unlock This Lesson

Already a member? Sign-In