Skip to content
Built-in Functions

map()

Apply a function to each item in one or more iterables.

map(function, *iterables)

map() returns an iterator that applies function to every item of iterable.

Parameters

NameDescription
functionThe function to call for each item.
*iterablesOne or more values to provide items from.

Returns

A map iterator.

Try it

Run it and change it
words = ["sun", "moon"]
print(list(map(str.upper, words)))

Worth knowing

  • Multiple iterables: Can accept multiple iterables: map(pow, [2, 3], [3, 2]) computes [8, 9].

Related entries