Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Python’s built-in zip() pairs items from iterables by position and yields them as tuples. By default, it stops when the shortest input runs out, so any remaining items in longer inputs are ignored. Use strict=True when lengths must match, or itertools.zip_longest() when you want to keep all items and pad shorter inputs.
What does Python’s zip() function do?
zip() takes one or more iterables—such as lists, tuples, or strings—and returns an iterator that produces tuples. Each tuple contains the items at the same position in each input. For example, the first tuple contains the first item from every iterable.
names = ["Ada", "Linus", "Grace"]
roles = ["mathematician", "systems programmer", "computer scientist"]
for name, role in zip(names, roles):
print(name, role)
This loop prints each name beside its corresponding role. The built-in functions reference documents the signature as zip(*iterables, strict=False) in the Python 3.14.7 documentation.
How do you consume the result?
zip() is lazy: calling it creates an iterator, but does not produce all the tuples immediately. Values are processed as the iterator is consumed, such as by a for loop or by passing it to list().
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
pairs = zip([1, 2, 3], ["a", "b", "c"])
print(list(pairs))
# [(1, 'a'), (2, 'b'), (3, 'c')]
Because the result is an iterator, it is normally consumed as you iterate over it. Converting it to a list materializes the tuples so you can inspect or reuse that list.
What happens when the input lengths differ?
With the default setting, zip() stops as soon as the shortest iterable is exhausted. It does not include the leftover items from longer inputs. That behavior is useful when you deliberately want to process only aligned pairs, but it can also conceal an unintended length mismatch.
Rank #2
list(zip([1, 2, 3], ["a", "b"]))
# [(1, 'a'), (2, 'b')]
The result has two tuples because the second input has only two items. Python’s documentation states: “By default, zip() stops when the shortest iterable is exhausted.”
Which option should you use for unequal lengths?
| Need | Use | Behavior |
|---|---|---|
| Pair items and ignore any unmatched tail | zip(a, b) |
Stops at the shortest input. |
| Require the inputs to have equal lengths | zip(a, b, strict=True) |
Raises ValueError if lengths differ. The parameter is available in Python 3.10 and later. |
| Keep every item and pad shorter inputs | itertools.zip_longest(a, b, fillvalue=...) |
Continues to the longest input, padding exhausted inputs. |
Use strict=True to detect a mismatch
When equal lengths are part of your program’s assumptions, set strict=True. If an input ends before another, iteration raises ValueError rather than silently discarding the longer input’s tail.
list(zip([1, 2, 3], ["a", "b"], strict=True))
# ValueError: zip() argument 2 is shorter than argument 1
The strict parameter was added in Python 3.10; code that uses it requires Python 3.10 or later. See the Python 3.10 built-in functions documentation.
Use zip_longest() to pad instead
If you need to preserve every item, import zip_longest() from itertools. It continues until the longest input is exhausted and fills missing positions with None by default. Set fillvalue to choose a different padding value.
from itertools import zip_longest
list(zip_longest([1, 2, 3], ["a", "b"], fillvalue="?"))
# [(1, 'a'), (2, 'b'), (3, '?')]
What are the zero- and one-input cases?
Calling zip() with no arguments returns an empty iterator. With one iterable, it yields one-element tuples, rather than returning the elements directly.
list(zip())
# []
list(zip(["a", "b"]))
# [('a',), ('b',)]
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Can zip() transpose or unzip data?
Yes. If you have rows of values, zip(*rows) groups items by column. The asterisk unpacks the rows as separate arguments to zip().
Best Value
rows = [(1, "a"), (2, "b"), (3, "c")]
columns = list(zip(*rows))
print(columns)
# [(1, 2, 3), ('a', 'b', 'c')]
You can also unpack paired data into separate sequences by unpacking a zipped iterator with *:
pairs = [(1, "a"), (2, "b"), (3, "c")]
left, right = zip(*pairs)
print(left) # (1, 2, 3)
print(right) # ('a', 'b', 'c')
How can zip() group an iterable into chunks?
A documented chunking idiom passes the same iterator repeatedly: zip(*[iter(series)] * size, strict=True). Each reference points to the same iterator, so each output tuple consumes the next size successive items.
series = [1, 2, 3, 4, 5, 6]
size = 3
chunks = list(zip(*[iter(series)] * size, strict=True))
print(chunks)
# [(1, 2, 3), (4, 5, 6)]
With strict=True, a final incomplete chunk raises ValueError. Use this pattern when every chunk must be complete; omit strict checking only if discarding a short final chunk is intentional. This idiom and the left-to-right evaluation order of iterable arguments are described in the Python 3.14.7 documentation.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




