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

Unlock This Lesson

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

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

What is the filter() Function?

Give Feedback

In this lesson, you’ll learn that filter() is one of the functional programming primitives (or building blocks) available in Python and that it’s useful in a number of contexts.

You’ll see how you can use filter() to play with your data set. You’ll write a filter expression to see which items in your data set meet particular criteria. filter() takes another function object, and you can define a function object inline with lambda expressions.

Comments & Discussion

brunofl on July 14, 2019

Nice work! how can I have a terminal or idle shell showing command help info like you did in these videos?

Dan Bader RP Team on July 15, 2019

Thanks @brunofl! I’m using an alternative Python REPL called bpython in my videos. You can learn more about it here: bpython-interpreter.org/

brunofl on July 17, 2019

Nice, I will give it a try. Thanks!

vtzast on April 1, 2020

Alternatively, in Python 3.x instead of using the next() we could use a list

list(filter(lambda x: x.nobel is True, scientists))

or a tuple

tuple(filter(lambda x: x.nobel is True, scientists))

Become a Member to join the conversation.