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
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-map-function
Python map() function - GeeksforGeeks
map() function in Python applies a function to every element of one or more iterables and returns a map object (iterator) containing the transformed results.
Published: June 26, 2026
🌐
W3Schools
w3schools.com › python › ref_func_map.asp
Python map() Function
Python Examples Python Compiler ... Plan Python Interview Q&A Python Training ... The map() function executes a specified function for each item in an iterable....
Discussions

python - Understanding the map function - Stack Overflow
The Python 2 documentation says: Built-in Functions: map(function, iterable, ...) Apply function to every item of iterable and return a list of the results. If additional iterable arguments are pa... More on stackoverflow.com
🌐 stackoverflow.com
The map() function or the list comprehension?
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: >>> lst = [1, 2, 3, 4] >>> [str(i) for i in ... More on discuss.python.org
🌐 discuss.python.org
5
1
September 12, 2023
Python - You need to know Map() Function!
map() has quite awkward position in Python when we already have list comprehension More on reddit.com
🌐 r/Python
12
0
April 29, 2023
What wonderful thing can I do with the map function as a beginner on python?
You might want to look into list comprehension (and generator expressions) first. A lot of what map, and its siblings, was used for has been supplanted by comprehensions. Guido van Rossum has said he regreted including map. That said, it is well suited for functional programming if that is more your style. It is very handy for applying a function you've already defined to a sequence from an iterable. Example: def celsius_to_fahrenheit(celsius): """Converts Celsius to Fahrenheit.""" return (celsius * 9/5) + 32 temperatures_celsius = [25, 10, 15.5, 30, 0] Using map with the custom function, temperatures_fahrenheit = list(map(celsius_to_fahrenheit, temperatures_celsius)) Using list comprehension with custom function, temperatures_fahrenheit = [celsius_to_fahrenheit(celsius) for celsius in temperatures_celsius] More on reddit.com
🌐 r/learnpython
11
6
March 23, 2025
🌐
Enki
enki.com › post › apply-a-function-to-each-element-in-a-list---python-s-map-function
Enki | Blog - Apply a Function to Each Element in a List - Python’s map function
The map() function in Python is a simple tool for applying a function to every item in an iterable, like a list. This turns data transformation into a straightforward task.
Top answer
1 of 6
532

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
100

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 › 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.
🌐
YouTube
youtube.com › bro code
Learn Python MAP() in 3 minutes! 🗺️ - YouTube
#python #pythonprogramming #pythontutorial # map(function, collection) = Applies a given function to all items in a collectioncelsius_temps = [0.0, 10.0, 20....
Published: July 15, 2024
Views: 2K
Find elsewhere
🌐
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: ...
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-map-lambda.html
Python Map Lambda
Lambda is perfect where you have a short computation to write inline. Many programs have some sub-part which can be solved very compactly this way. For longer code, def is better. The map() function runs a lambda function over the list [1, 2, 3, 4, 5], building a list-like collection of the results...
🌐
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.
🌐
YouTube
youtube.com › watch
How to Use map() in Python | Python Map Function Explained with Real Examples - YouTube
📌 Learn How to Use map() Function in Python | Apply Functions to Iterables Like a Pro ()Want to write cleaner, faster, and more Pythonic code? In this video...
Published: June 9, 2025
🌐
Python
docs.python.org › 3 › builtins › functions.html
Built-in Functions — Python 3.14.8 documentation
Rather than being a function, list ... tuple, range. ... Return a mapping object representing the current local symbol table, with variable names as the keys, and their currently bound references as the values....
🌐
CodeSignal
codesignal.com › learn › courses › standard-higher-order-functions-in-python › lessons › exploring-the-map-function
Exploring the map Function | CodeSignal Learn
Lambda functions are small anonymous functions defined using the lambda keyword. They are often used for simple operations. Let's recall their syntax: ... if __name__ == "__main__": numbers = [1, 2, 3, 4, 5] # Use map with a lambda function to square each number squared = map(lambda x: x ** 2, numbers) print(list(squared)) # [1, 4, 9, 16, 25]
🌐
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.
🌐
Medium
medium.com › @engr.tanveersultan53 › python-map-function-3c3878b8f3bd
Python map() Function. Processing Iterables Without a using a… | by Engr Muhammad Tanveer sultan | Medium
August 25, 2021 - the map function get element one by one from the list of dict and set on which the map function apply and send the element to the specified function which is given or pass the first args/parameter of the map.
🌐
Tutorialspoint
tutorialspoint.com › python › python_map_function.htm
Python map() Function
The Python map() function is a built-in function that allows us to transform each item from an iterable with the help of a process known as mapping. In this process, the map() function applies a function on every element of the given iterable and
🌐
Python Morsels
pythonmorsels.com › map-and-filter-python
Python's map and filter functions - Python Morsels
August 3, 2026 - In this case, we're only getting ... function (is_odd in our case). The map function takes each item in a given iterable and includes all of them in a new lazy iterable, transforming each item along the way...
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-the-python-map-function
Ultimate Guide to Python Map Function for Data Processing | DigitalOcean
Master Python’s map() function with easy examples! Learn its syntax, lambda functions, user-defined functions, and using multiple iterables to optimize funct…
🌐
Programiz
programiz.com › python-programming › methods › built-in › map
Python map() Function
The map() function executes a given function to each element of an iterable (such as lists,tuples, etc.).