The map()
is similar to filter()
as in it iterates over all the values of the list. The map()
function however does not discard any value but instead processes using the given function and stores the return value within the list instead.
In the example above, we add Mr. to every name in names using map()
. The map()
function calls add_salutation()
for every name and adds Mr. to it. Note that we could also use a lambda function instead of defining add_salutation()
.