Web Analytics

Python zip() Function

Built-in Function β€’ Iterator

The zip() function returns a zip object, which is an iterator of tuples where the first item in each passed iterator is paired together, and then the second item in each passed iterator are paired together etc.

If the passed iterators have different lengths, the iterator with the least items decides the length of the new iterator.

Syntax

zip(iterables)

Parameters

Parameter Description
iterables Optional. Iterables (list, tuple, etc.) to zip together

Return Value

A zip object (iterator of tuples).

Example

Using the zip() function:

Output
Click Run to execute your code

Related Functions