I have a two lists, and I want to combine them in an alternating fashion, until one runs out, and then I want to keep adding elements from the longer list.
Aka.
list1 = [a,b,c]
list2 = [v,w,x,y,z]
result = [a,v,b,w,c,x,y,z]
Similar to this question (Pythonic way to combine two lists in an alternating fashion?), except in these the lists stop combining after the first list has run out :(.
You might be interested in this
itertools
recipe:For example:
My solution:
EDIT: Question specifies the longer list should continue at end of shorter list, which this answer does not do.
Here is the simpler version from the excellent toolz:
You could use plain
map
and list comprehension: