zip() Parallel iteration

Last updated: 2026-09-22

zip() Parallel iteration

zip(*iterables) combines iterables in parallel, stopping at the shortest (or raising if strict=True).

CategoryBuilt-in Functions
KindBuilt-in Function
Python Version3.10+

📝 Syntax

zip(*iterables, strict=False)

⚙️ Parameters

iterables RequiredVarargs: multiple iterables combined in parallel.
strict OptionalWhen True, require equal lengths (Python 3.10+).(Default:False)

Returns:An iterator of tuples pairing same-index elements; stops at the shortest input.

💥 Raises

▶ Example

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

Output:

a 1
b 2
c 3
More case studies coming soon — check back later.

❓ FAQ

QWhat happens when zip() meets two sequences of unequal length?
ABy default it truncates at the shortest, discarding extra elements — e.g. zip('abc', '12') only yields ('a','1') and ('b','2'); to raise an explicit error use zip(a, b, strict=True) (Python 3.10+).
QWhat does zip(*lst) do?
AIt unpacks and transposes: zip(*[(1, 'a'), (2, 'b')]) gives (1, 2) and ('a', 'b'), turning 'rows' into 'columns' — commonly used for matrix transposition.
QWhat does zip() return?
AIt returns a lazy zip iterator; use list(zip(...)) to get a list, and calling it with no arguments returns an empty iterator.
QHow many lists can zip() iterate over at once?
AAny number: for a, b, c in zip(x, y, z): pulls values in parallel, the standard way to traverse several sequences at once.
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%

🙏 帮我们做得更好

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

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