How to combine two lists by alternatively taking elements. For example: given the two lists ['a','b','c'] and [1, 2, 3, 4], the function should return [a, 1, b, 2, c, 3, 4]
Asked
Active
Viewed 560 times
1 Answers
0
a = [1, 2, 3, 4]
b = ['a','b','c']
result = [item for sublist in zip(b,a) for item in sublist]
print result

pSaadi
- 190
- 9
-
1swap `zip(a,b)` for `zip(b,a)` – Scott May 09 '15 at 06:01