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
It is commonly used for element-wise operations and can often replace explicit loops with shorter and more readable code. Let's start with a simple example of using map() to convert a list of strings into a list of integers.
Published: June 26, 2026
🌐
W3Schools
w3schools.com › python › ref_func_map.asp
Python map() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The map() function executes a specified function for each item in an iterable.
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']]
🌐
DataCamp
datacamp.com › tutorial › python-map-function
Python map() Function: A Complete Guide | DataCamp
December 10, 2025 - If you want to build upon the new ... entire list in memory at once. For example, list(map(lambda x, y: x + y, [1, 2], [10, 20])) adds elements from two lists, resulting in [11, 22]....
🌐
freeCodeCamp
freecodecamp.org › news › python-map-explained-with-examples
Python map() – List Function with Examples
April 23, 2025 - An example of this would be the pow(x, y) function that takes in 2 arguments (it returns the result of x^y). To apply a function with multiple arguments, simply pass in another iterable name following the first one. base = [1, 2, 3, 4] power ...
🌐
Programiz
programiz.com › python-programming › methods › built-in › map
Python map() Function
Here, the map() function squares each element of the tuple using the square function. The initial output <map object at 0x7f722da129e8> represents a map object · Finally, we convert the map object to a set and obtain the squared values of each element in tuple.
🌐
Real Python
realpython.com › ref › builtin-functions › map
map() | Python’s Built-in Functions – Real Python
In this example, you use map() to convert a list of temperatures in Celsius into Fahrenheit by applying the to_fahrenheit() function to each item in the input list. ... Learn how Python's map() transforms iterables without loops, and when to ...
🌐
Real Python
realpython.com › python-map-function
Python's map(): Processing Iterables Without a Loop – Real Python
March 18, 2026 - This behavior changed in Python ... desired list object. For another example, say you need to convert all the items in a list from a string to an integer number....
Find elsewhere
🌐
Guru99
guru99.com › home › python › python map() function with examples
Python map() Function with EXAMPLES
July 10, 2026 - The map() function applies the function square() on all the items in the list. For example, it takes the my_list variable and updates the list with the square of each number. The output is stored in the updated_list variable.
🌐
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…
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-map-function
Python map() function | DigitalOcean
Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
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
🌐
Simplilearn
simplilearn.com › home › resources › software development › map function in python: simplify iterative operations
Map Function in Python: Simplify Iterative Operations
February 15, 2026 - 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
🌐
Tutorial Teacher
tutorialsteacher.com › python › python-map-function
Python map() Function (With Examples)
>>> numbers=[1, 2, 3, 4, 5] >>> sqrs_of_numbers=map(square, numbers) >>> next(sqrs_of_numbers) 1 >>> next(sqrs_of_numbers) 4 >>> next(sqrs_of_numbers) 9 >>> next(sqrs_of_numbers) 16 >>> next(sqrs_of_numbers) 25 · In the above example, the map() function applies to each element in the numbers list.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › map.html
map — Python Reference (The Right Way) 0.1 documentation
>>> map(lambda x: x+x, (1, 2, 3)) [2, 4, 6] >>> map(lambda x, y: x/y, (1, 4, 9), (1, 2, 3)) [1, 2, 3] >>> map(lambda x, y, z: x+y+z, (1, 2, 3), (1, 4, 9), (1, 16, 27)) [3, 22, 39]
🌐
Medium
medium.com › pythoneers › understanding-how-maps-work-in-python-ce7102539bad
Understanding How Maps Work in Python | by Rajat Sharma | The Pythoneers | Medium
April 13, 2024 - Creating a map, or dictionary, in Python is straightforward. You can initialize an empty dictionary or create one with predefined key-value pairs using curly braces {} and colons : to separate keys and values, respectively. Here's an example:
🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › python map() function: syntax, usage, examples
Python map() Function: Syntax, Usage, Examples
November 20, 2025 - For example, to round a list of numbers, use the built-in round() function with map(): ... The function rounds all the numbers in the list. Provide multiple iterables to a map() function to apply functions with multiple arguments.
🌐
Geocompx
py.geocompx.org › 08-mapping
8 Making maps with Python – Geocomputation with Python
Let’s move on to the basics of static mapping with Python. A vector layer (GeoDataFrame) or a geometry column (GeoSeries) can be displayed using their .plot method (Section 1.2.2). A minimal example of a vector layer map is obtained using .plot with nothing but the defaults (Figure 8.1).
🌐
Mimo
mimo.org › glossary › python › map-function
Python Map Function: Streamline Data Transformation Efforts
... numbers1 = [1, 2, 3] numbers2 = [4, 5, 6] result = map(lambda x, y: x + y, numbers1, numbers2) print(list(result)) # Outputs: [5, 7, 9] Data analytics platforms can use map() to preprocess and filter data. For example, they might filter out negative numbers and double the remaining values.
🌐
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