August 2018
Intermediate to advanced
366 pages
10h 14m
English
Zip will make a new iterable where each item in the newly-created iterable is a collection that is made by picking one item for each one of the provided iterables.
So, result[0] = (i[0], j[0]), and result[1] = (i[1], j[1]), and so on. If i and j have different lengths, it will stop as soon as one of the two is exhausted.
If you want to proceed until you exhaust the longest one of the provided iterables instead of stopping on the shortest one, you can rely on itertools.zip_longest. Values from the iterables that were already exhausted will be filled with a default value.
Read now
Unlock full access