The purpose of this function is to build a list of tuples from two or more iterables of the same length. Here is the general form:
zip(S0,S1,S2, ...)
Each must be in iterable. The
result is a list Si[, where
each T0, T1, ...] is the tuple
Ti(.
S0[i],
S1[i],
S2[i],
...)
Here are some examples.
>>> L1=[1,2,3,4] >>> L2=['a', 'b', 'c', 'd'] >>> zip(L1, L2) [(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd')] >>> L3=[10.0, 20.0, 30.0, 40.0] >>> zip(L1, L2, L3) [(1, 'a', 10.0), (2, 'b', 20.0), (3, 'c', 30.0), (4, 'd', 40.0)]