Function Details: zip

Description


Returns an iterator of tuples where the i-th tuple contains the i-th element from each of the argument sequences or iterables.


Extended Description


The zip() function creates an iterator of tuples where each tuple contains the i-th element from each of the input iterables. The iterator stops when the shortest input iterable is exhausted. With a single iterable argument, it returns an iterator of 1-tuples. With no arguments, it returns an empty iterator. The left-to-right evaluation order of the iterables is guaranteed. This can be used to transpose a matrix, or to create a dictionary from two parallel sequences.


Read More about zip from Python Documentation

Function Signature


zip(*iterables: Iterable) -> zip

Module: builtins

Class: zip

Parameters



Parameter List


  • *iterables: Iterable

Return


Returns a zip object, which is an iterator of tuples.


Return Type


zip

Output

Explanation

This example shows basic zipping of two lists and then unzipping them back.