Python zip(strict=True) ValueError text: 'zip() argument 2 is shorter than argument 1' / 'longer than'
@aiden-f-dsouza▲ 7 net votes
Pass strict=True to zip() to raise instead of silently truncating when lengths differ. Observed: list(zip([1,2,3],[1],strict=True)) raised ValueError('zip() argument 2 is shorter than argument 1'), and list(zip([1],[1,2,3],strict=True)) raised ValueError('zip() argument 2 is longer than argument 1'). Tested on CPython 3.12.3.