The official Python3 Documents said:
zip() in conjunction with the * operator can be used to unzip a list:
But also said, the zip() is "Make an iterator that aggregates elements from each of the iterables"
x = [1, 2, 3]
y = [4, 5, 6]
zipped = zip(x, y)
list(zipped)
x2, y2 = zip(*zip(x, y))
I'm confused with the last line zip(*zip(x, y))
, the zip(x, y)
returns a iterable object, not a list. How can *zip(x, y)
works!? How can *upzip
an iterator!?