The zip function takes two collections and merges them. The collections must be of equal length. Collections are : lists, tuples and the dictonaries. All examples are Python 3 code.
If we have two lists of eight elements:
a = list(range(8))
Just having the data:
[0, 1, 2, 3, 4, 5, 6, 7]
We can combine them:
a = range(8)
The list ab then contains:
All elements in the list are now pairs. If we merge three lists, we would get a pair of 3 for each element.
We can convert two lists to a dictionary:
This will output: