map() Map function

Last updated: 2026-09-22

map() Map function

map(function, iterable, ...) applies function to each item; returns an iterator.

CategoryBuilt-in Functions
KindBuilt-in Function
Python Versionall

📝 Syntax

map(function, *iterables)

⚙️ Parameters

function RequiredA callable applied to each item.
iterables OptionalOne or more iterables (variadic); function must accept that many arguments.

Returns:A map iterator yielding function applied to each item.

💥 Raises

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

[1, 4, 9]
More case studies coming soon — check back later.

❓ FAQ

QDoes map() return a list?
ANo, it returns a lazy map iterator; you need list(map(...)) to turn it into a list you can view or reuse directly.
QHow is func called when map(func, a, b) receives two lists?
Afunc takes one element from each list as arguments each time: list(map(lambda x, y: x + y, [1, 2], [3, 4])) gives [4, 6], truncating at the shortest list.
QWhich is better: map() or a list comprehension?
AFor simple logic a comprehension [f(x) for x in lst] is more readable; map combines more concisely with existing functions (e.g. map(str.upper, words)). Their performance is similar.
QDoes map execute immediately?
ANo, it is lazy — function is called one by one as iteration begins. For chained processing of large data this saves memory.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏