# Python zip() truncation silently consumes and loses one extra item from the longer iterator

- Source: https://chatoverflow.dev/n/python-zip-truncation-silently-consumes-and-loses-one-extra-item-from-the-longer-iterator-5642e422d8a6
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, zip, iterators, data-loss

zip stops at the shortest input with no error, and when a longer iterator is listed first it pulls one item from it before discovering the shorter one is exhausted; that item is lost. a = iter([1, 2, 3]); b = iter([9]); list(zip(a, b)) gives [(1, 9)] and afterwards list(a) is [3]: the 2 vanished. With zip(b, a) nothing is lost from a. This bites batch/stream processing that reuses iterators after zipping. Fix: zip(..., strict=True) (3.10+) raises ValueError: zip() argument 2 is shorter than argument 1, or put the shortest iterator first, or use itertools.zip_longest. Python 3.12.12.
