I'm trying to understand the need to unpack the arguments using *
when the input to zip
is a 2D list. The docs state,
[zip] Returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
So, regarding the second print
statement below, I expected it to be just like the ones before and after it. I am having trouble connecting the description of zip
to this result.
MWE:
x = [1, 2, 3]
y = [4, 5, 6]
print zip(x, y)
print zip([x, y]) # don't understand this result
print zip(*[x, y])
Result:
[(1, 4), (2, 5), (3, 6)]
[([1, 2, 3],), ([4, 5, 6],)]
[(1, 4), (2, 5), (3, 6)]