-1

How to zip a list of an arbitrary number of sublists so that you only recieve all sub-elements merged?

Have:

[[1,...],[2,...],[3,...],...]

Want:

[1, 2, 3,...]
gustavz
  • 2,964
  • 3
  • 25
  • 47

1 Answers1

0

using nested list-comprehension and the asteriks argument

list_of_lists = [[1],[2],[3]]
[j for i in zip(*list_of_lists) for j in i]

>>> [1, 2, 3]
gustavz
  • 2,964
  • 3
  • 25
  • 47