map isn't particularly pythonic. I would recommend using list comprehensions instead:

map(f, iterable)

is basically equivalent to:

[f(x) for x in iterable]

map on its own can't do a Cartesian product, because the length of its output list is always the same as its input list. You can trivially do a Cartesian product with a list comprehension though:

[(a, b) for a in iterable_a for b in iterable_b]

The syntax is a little confusing -- that's basically equivalent to:

result = []
for a in iterable_a:
    for b in iterable_b:
        result.append((a, b))
Answer from dave on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_func_map.asp
Python map() Function
Python Examples Python Compiler ... Python Certificate Python Training ... The map() function executes a specified function for each item in an iterable....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-map-function
Python map() function - GeeksforGeeks
map() function in Python applies a given function to each element of an iterable (list, tuple, set, etc.) and returns a map object (iterator).
Published   September 7, 2025
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
2 weeks ago - If only globals is provided, it must be a dictionary (and not a subclass of dictionary), which will be used for both the global and the local variables. If globals and locals are given, they are used for the global and local variables, respectively. If provided, locals can be any mapping object.
🌐
Programiz
programiz.com › python-programming › methods › built-in › map
Python map() Function
Become a certified Python programmer. Try Programiz PRO! ... The map() function executes a given function to each element of an iterable (such as lists, tuples, etc.).
🌐
Real Python
realpython.com › ref › builtin-functions › map
map() | Python’s Built-in Functions – Real Python
The built-in map() function in Python allows you to apply a transformation function to each item of one or more iterables, producing an iterator that yields transformed items.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-map-function
Python map() function | DigitalOcean
August 3, 2022 - Python map() function is used to apply a function on all the elements of specified iterable and return map object. Python map object is an iterator, so we can iterate over its elements. We can also convert map object to sequence objects such as list, tuple etc.
🌐
DataCamp
datacamp.com › tutorial › python-map-function
Python map() Function: A Complete Guide | DataCamp
December 10, 2025 - Optional additional iterables allow broadcasting the function across zipped sequences, which are perfect for vectorized operations akin to NumPy's apply_along_axis(). In Python 3, map() returns a map object, an iterator subclass, rather than a list.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-the-python-map-function
Ultimate Guide to Python Map Function for Data Processing | DigitalOcean
December 18, 2024 - We can use the Python built-in function map() to apply a function to each item in an iterable (like a list or dictionary) and return a new iterator for retrieving the results. map() returns a map object (an iterator), which we can use in other parts of our program.
Find elsewhere
Top answer
1 of 6
529

map isn't particularly pythonic. I would recommend using list comprehensions instead:

map(f, iterable)

is basically equivalent to:

[f(x) for x in iterable]

map on its own can't do a Cartesian product, because the length of its output list is always the same as its input list. You can trivially do a Cartesian product with a list comprehension though:

[(a, b) for a in iterable_a for b in iterable_b]

The syntax is a little confusing -- that's basically equivalent to:

result = []
for a in iterable_a:
    for b in iterable_b:
        result.append((a, b))
2 of 6
99

map doesn't relate to a Cartesian product at all, although I imagine someone well versed in functional programming could come up with some impossible to understand way of generating a one using map.

map in Python 3 is equivalent to this:

def map(func, iterable):
    for i in iterable:
        yield func(i)

and the only difference in Python 2 is that it will build up a full list of results to return all at once instead of yielding.

Although Python convention usually prefers list comprehensions (or generator expressions) to achieve the same result as a call to map, particularly if you're using a lambda expression as the first argument:

[func(i) for i in iterable]

As an example of what you asked for in the comments on the question - "turn a string into an array", by 'array' you probably want either a tuple or a list (both of them behave a little like arrays from other languages) -

 >>> a = "hello, world"
 >>> list(a)
['h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd']
>>> tuple(a)
('h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd')

A use of map here would be if you start with a list of strings instead of a single string - map can listify all of them individually:

>>> a = ["foo", "bar", "baz"]
>>> list(map(list, a))
[['f', 'o', 'o'], ['b', 'a', 'r'], ['b', 'a', 'z']]

Note that map(list, a) is equivalent in Python 2, but in Python 3 you need the list call if you want to do anything other than feed it into a for loop (or a processing function such as sum that only needs an iterable, and not a sequence). But also note again that a list comprehension is usually preferred:

>>> [list(b) for b in a]
[['f', 'o', 'o'], ['b', 'a', 'r'], ['b', 'a', 'z']]
🌐
Real Python
realpython.com › python-map-function
Python's map(): Processing Iterables Without a Loop – Real Python
July 31, 2023 - Python’s map() is a built-in function that allows you to process and transform all the items in an iterable without using an explicit for loop, a technique commonly known as mapping. map() is useful when you need to apply a transformation ...
🌐
TutorialsPoint
tutorialspoint.com › home › python_data_structure › python maps
Understanding Python Maps
February 21, 2009 - Python Maps also called ChainMap is a type of data structure to manage multiple dictionaries together as one unit. The combined dictionary contains the key and value pairs in a specific sequence eliminating any duplicate keys.
🌐
Python.org
discuss.python.org › python help
The map() function or the list comprehension? - Python Help - Discussions on Python.org
September 12, 2023 - There are two ways to apply a function to each element of an iterated object in python: the map function: >>> lst = [1, 2, 3, 4] >>> list(map(str, lst)) ['1', '2', '3', '4'] >>> list(map(lambda a: a + 1, lst)) [2, 3, 4, 5] the list comprehension: ...
🌐
Mimo
mimo.org › glossary › python › map-function
Python Map Function: Streamline Data Transformation Efforts
In Python, the function map() is useful for applying a transformation to each item of a sequence.
🌐
Tutorial Teacher
tutorialsteacher.com › python › python-map-function
Python map() Function (With Examples)
Regex in Python · Create GUI using ... Update · Bulk Merge · The map() function applies the specified function to every item of the passed iterable, yields the results, and returns an iterator....
🌐
Plotly
plotly.com › python › maps
Maps in Python
Plotly's Python graphing library makes interactive, publication-quality maps online.
🌐
freeCodeCamp
freecodecamp.org › news › python-map-explained-with-examples
Python map() – List Function with Examples
April 23, 2025 - The map() function (which is a built-in function in Python) is used to apply a function to each item in an iterable (like a Python list or dictionary).
🌐
AskPython
askpython.com › home › python map() method
Python map() Method - AskPython
January 25, 2026 - The python map function applies a transformation to every element in an iterable without writing explicit loops. You pass a function and one or more
🌐
Simplilearn
simplilearn.com › home › resources › software development › map function in python: simplify iterative operations
Map Function in Python: Simplify Iterative Operations
1 month ago - Learn how to use the map function in Python to simplify iterative operations. Discover its benefits, usage, and practical examples for efficient coding.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › map.html
map — Python Reference (The Right Way) 0.1 documentation
If one iterable is shorter than another it is assumed to be extended with None items. If function is None, the identity function is assumed; if there are multiple arguments, map() returns a list consisting of tuples containing the corresponding items from all iterables (a kind of transpose ...
🌐
IONOS
ionos.com › digital guide › websites › web development › python map
How to use Python map() - IONOS
July 18, 2023 - The Python map function is an elegant way to process the contents of iterables. Iterables are Python objects that can be iterated. Both Python lists and Python tuples can be iterables.