I was seeking a solution for Pythonic way to combine two lists in an alternating fashion? And I came across this elegant solution by @Someone.
[x for y in zip(list1, list2) for x in y]
It works like a charm, but I do not understand how the variables x
and y
are being assigned here. What is really going on in the list comprehension?