-1

I have [[1,2,3], [5,6,7]] and want to produce the list [[1,5], [2,6], [3,7]]. How do I do this in Python?

Kijewski
  • 25,517
  • 12
  • 101
  • 143

2 Answers2

0
>>> zip([1,2,3], [4, 5, 6])
[(1, 4), (2, 5), (3, 6)]

To convert each element to a list

>>> [list(a) for a in  zip([1, 2, 3], [4, 5, 6])]
[[1, 4], [2, 5], [3, 6]]
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
0
result = [list(x) for x in zip([1, 2, 3], [5, 6, 7])]
zs2020
  • 53,766
  • 29
  • 154
  • 219