PyDocs

Nav

Python Runtime Services

zip

builtins

function
  • zip(*iterables, strict=False)
The zip object yields n-length tuples, where n is the number of
iterables passed as positional arguments to zip().  The i-th element
in every tuple comes from the i-th iterable argument to zip().  This
continues until the shortest argument is exhausted.

If strict is true and one of the arguments is exhausted before the
others, raise a ValueError.

   >>> list(zip('abcdefg', range(3), range(4)))
   [('a', 0, 0), ('b', 1, 1), ('c', 2, 2)]
Changed in 3.10
  • 3.10: Added the strict argument.
1 Example
>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
...     print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
from the Python docs
See Also
No see-alsos for builtins/zip
0 Notes
No notes for zip