A particularly useful function for lists is zip. It can be used to merge two given lists into a new list by pairing the elements of the original lists. The result is a list of tuples (see Section 3.3: Tuples):
ind = [0,1,2,3,4] color = ["red", "green", "blue", "alpha"] list(zip(color,ind))
# gives [('red', 0), ('green', 1), ('blue', 2), ('alpha', 3)]
This example also demonstrates what happens if the lists have different lengths: the length of the zipped list is the shorter of the two input lists.
The function zip creates a special iterable object that can be turned into a list by applying the function list, as in the preceding example. See Section 9.3: Iterable objects for more details on iterable objects.