Map6:35 with Kenneth Love
More than just a friend of Dora or a way to find things, `map()` lets us apply transformations to each item in an iterable.
map() takes a function and an iterable. The function should take a single argument. This function will be applied, in order, to each item in the iterable and the result of that function will be returned to
map(). In the end,
map() will return a new iterable with the mutated values.
[func(item) for item in iterable] achieves the same result, plus turns the results into a list. For simple, single-serving applications, this is often a better choice since it's often more readable at a glance.
Watch our comprehensions workshop if you want more information.
You need to sign up for Treehouse in order to download course files.Sign up