jarrod817
11/17/2016 - 1:32 AM

Using zip to put lists together and take them apart.

Using zip to put lists together and take them apart.

x = [1, 2, 3]
y = [4, 5, 6]
zipped = zip(x, y)
list(zipped)
[(1, 4), (2, 5), (3, 6)]
x2, y2 = zip(*zip(x, y))
x == list(x2) and y == list(y2)
True