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
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-map-function
Python map() function | DigitalOcean
August 3, 2022 - 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.
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']]
🌐
W3Schools
w3schools.com › python › ref_func_map.asp
Python map() Function
Python Examples Python Compiler ... ('apple', 'banana', 'cherry')) Try it Yourself » · The map() function executes a specified function for each item in an iterable....
🌐
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
When you want to apply a single ... structure, leaving you with an iterator of the modified results. ... Being lazy, map() returns a map object instead of modifying the list directly....
🌐
Real Python
realpython.com › ref › builtin-functions › map
map() | Python’s Built-in Functions – Real Python
Returns a map object that generates items by applying a transformation function to every item of the input iterable or iterables.
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › python-map-function
Python map() Function: A Complete Guide | DataCamp
December 10, 2025 - In Python 3, map() does not immediately run your function and return a list. Instead, it returns a map object, which is an iterator.
🌐
Medium
medium.com › @yusuf.aziz › object-mapper-in-python-12d21bcaf056
Object-Mapper In Python. Why do we need an Object-Mapper? | by Yusuf Malkan | Medium
January 3, 2023 - A Python library called object-mapper (docs). It helps us easily and transparently construct objects between application layers (data layer, service layer, and view).
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.8 documentation
June 26, 2026 - Another useful data type built ... (see Mapping Types — dict). Dictionaries are sometimes found in other languages as “associative memories” or “associative arrays”. Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always be keys. Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly ...
🌐
Real Python
realpython.com › python-mappings
Python Mappings: A Comprehensive Guide – Real Python
March 18, 2026 - By working through this quiz, you'll revisit the key concepts and techniques of creating a custom mapping. A mapping is a collection that allows you to look up a key and retrieve its value. The keys in mappings can be objects of a broad range ...
🌐
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
🌐
AskPython
askpython.com › python › built-in-methods › map-method-in-python
Python map() Function: Transform Iterables Without Writing a Loop - AskPython
3 weeks ago - The kept list answers every later use. Treat the map object as a one-way pipe and the list as storage.
🌐
YouTube
youtube.com › watch
Python Map Function - YouTube
Learn how to use the Python map() function to apply a function to every value in an iterable, such as a list.Check out the written tutorial here: https://dat...
Published: May 16, 2022
🌐
Learn Python
learnpython.org › en › Map,_Filter,_Reduce
Map, Filter, Reduce - Learn Python - Free Interactive Python Tutorial
In Python 2, the map() function returns a list. In Python 3, however, the function returns a map object which is a generator object. To get the result as a list, the built-in list() function can be called on the map object.
🌐
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.
🌐
Python
docs.python.org › 3 › builtins › functions.html
Built-in Functions — Python 3.14.8 documentation
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set). CPython implementation detail: len raises OverflowError on lengths larger than sys.maxsize, such as range(2 ** 100). ... Rather than being a function, list is actually a mutable sequence type, as documented in Lists and Sequence Types — 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.