Not sure how to get this guy done...
have:
L1 = [1,2,3]
L2 = [a,b,c]
want:
[1,a,2,b,3,c]
import itertools
L1 = [1,2,3]
L2 = ['a','b','c']
list(itertools.chain.from_iterable(itertools.izip(L1, L2)))
You could use izip_longest with a fill value for lists of uneven length.
Zip the lists then flatten the result:
Z = zip(L1, L2)
print [x for item in Z for x in item]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With