EDIT: Unlike python: flat zip, I'm asking about a list of lists, not two lists.
I have a list of lists, for example:
[[a,b,c], [d,e,f], [g,h,i,j,k]]
And I wish to interleave them such that we take the first of each list, then the second, then the third, etc. In this example case we would get:
[a,d,g,b,e,h,c,f,i,j,k]
My pretty naive implementation:
output_list = []
while len(input_lists) > 0:
for i in range(len(input_lists)):
element = test_sets[i][0]
input_lists[i] = input_lists[i][1:]
output_list.append(element)
input_lists = [l for l in input_lists if len(l) > 0]
What's a more elegant solution?