How Python's zip pairs lists
pythoniteration
zip walks several lists in step, taking the item at the same position from each and yielding them together as a tuple. It stops as soon as the shortest list runs out, so the leftover items of longer lists are never read.
pair_up.py
def pair_up(a, b):
pairs = []
for left, right in zip(a, b):
pairs.append((left, right))
return pairs