Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only.Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Filter Iterables With Python (Summary)
Python’sfilter() allows you to performfiltering operations on iterables. This kind of operation consists of applying aBoolean function to the items in an iterable and keeping only those values for which the function returns a true result. In general, you can usefilter() 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()toprocess iterables and keep the values you need - Combine
filter()withmap()andreduce()to approach different problems - Replace
filter()withlist comprehensions andgenerator expressions
With this new knowledge, you can now usefilter() in your code to give it afunctional style. You can also switch to a more Pythonic style and replacefilter() withlist comprehensions orgenerator expressions.
For further investigation, check out:
00:00Congratulations, you just aced this course!
00:05In this course, you understood the concept of filtering.You used thefilter() function to keep the things you need and filter out therest. You solved examples for both numbers and strings.
00:18You discovered themap() function and learned how you can use it to apply a functionto each element of an iterable and also discovered thereduce() functionand learned how you can combine elements of a sequence to produce a single result.
00:33Then you learned that by combiningreduce(),map(), andfilter(),you can achieve complex tasks with minimal code.
00:41You used thefilterfalse() function to keep elements that don’t meet the filteringcondition, unlike thefilter() function.And you also learned how to replacefilter() with list comprehensions andgenerators.
00:55If you’d like to learn more about Python iterators,lambda functions, and generator functions,check out these awesome Real Python courses and tutorials:Iterators and Iterables in Python, which is a written tutorial;How to Use Python Lambda Functions,which is both a video course and a written tutorial; and, as promised,How to Use Generators andyield in Python,which is both a video course and a written tutorial.
01:24This has been Negar with Real Python.Tell us what you think about this course and your favorite things that you’velearned in the comments. Stay awesome.
Marco Perez onJuly 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!

Negar VahidRP Team onJuly 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.
Course Contents
- Get Started With filter()
- Use filter() for Functional Programming
- Code With Pythonic Style

