0

I have:

A = ['a1', 'a2', 'a3']
B = ['b1', 'b2', 'b3']

I am trying to get (ideally by one line of code):

['a1', b1', 'a2', 'b2', 'a3', 'b3']

I can get

[('a1', 'b1'), ('a2', 'b2'), ('a3', 'b3')]

from

[(i,j) for i,j in zip(A,B)]

but then I will need to work on flattening it.

pingboing
  • 55
  • 8
  • 1
    `[(i,j) for i,j in zip(A,B)]` should just be `list(zip(A, B))` to begin with. But to get what you want, you need to nest deeper: `[p for pair in zip(A,B) for p in pair]` – juanpa.arrivillaga Sep 15 '21 at 00:57

0 Answers0