Merge multiple 2d lists considering axis in order

axis, merge, python

Solution

You can use `zip` and a list comprehension:

>>> a = [[1,2],[3,1]]
>>> b = [[3,6],[2,9]]
>>> c = [[5,1],[8,10]]
>>> [x+y+z for x,y,z in zip(a, b, c)]
[[1, 2, 3, 6, 5, 1], [3, 1, 2, 9, 8, 10]]
>>>

Problem

My purpose is to combine multiple 2d list in order such as: ``` a = [[1,2],[3,1]] b= [[3,6],[2,9]] c = [[5,1],[8,10]] Expected: [[1,2,3,6,5,1],[3,1,2,9,8,10]] ``` Following other's advice from this site, I tried to use collections module like the code below: ``` from collections import Counter a = [[1,2],[3,1]] b= [[3,6],[2,9]] c = [[5,1],[8,10]] d = [[k,v] for k,v in (Counter(dict(a)) + Counter(dict(b))+ Counter(dict(c))).items()] print d ``` However, the result is `[[1, 2], [3, 1], [3, 6], [2, 9]]` which is not what I expected. Do you have any idea to solve this problem? Maybe if there is function or module to consider the axis to combine the lists.

Original source