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.

How to Use the map() Function

Give Feedback

In this lesson, you’ll learn how to use the map() function in Python in order to apply a function to all of the elements of an iterable and output an iterator of items that are the result of that function being called on the items in the first iterator.

You’ll walk through a practical example of how to use the map() function with the example data set that you’ve been working with in this course so far. You’ll know how to get a new iterable containing all of the information that you need from the old iterable, but you won’t modify the old iterable in the process!

Comments & Discussion

Shay Elmualem on Aug. 3, 2019

This is great stuff Dan, thanks! I normally, out of habit, just go with the “manual” approach of iterating/looping over and just getting/saving the data I need, I really need to start using these built-ins more! very cool.

Donna van Wyk on Sept. 24, 2019

Wow. I’ve been learning about python a lot of diff ways. Your “simple” explanation of a lambda here finally made it click. I am so excited to go thru all of the courses and really get somewhere.

agarwalamit081 on Aug. 1, 2020

By using the dictionary first and then converting to a tuple for the filtered results, we have now lost the original order of the filtered result. Is there a way to avoid this?

Dan Bader RP Team on Aug. 2, 2020

On Python 3.6 and above, dict retains the original insertion order automatically. On older Python versions, including Python 2.x, you can use the OrderedDict class from the standard library.

Become a Member to join the conversation.