I have the following list:
geo=[
[ ['a'], ['b','c'] ],
[ ['d','e'], ['f','g','h'] ],
[ ['i'] ]
]
My aim is to get a list of sublists: first sublist with elements in 1st position in original subsublist, second sublist with elements in 2nd position, third sublist with elemnts in 3rd position, and so on... In other words I need:
result=[
['a','b','d','f','i'],
['c','e','g'],
['h']
]
Bear in mind that number of elements in subsublist may vary, and number of subsublists inside sublists too. Unfortunately I cannot use Pandas or Numpy.
With zip
and Alex Martelli's approach to flatten lists, I've been able to get a list with a tuple of firsts elements, but I cannot iterate along the rest of elements.
result=zip(*[item for sublist in geo for item in sublist])
# [('a', 'b', 'd', 'f', 'i')]
This is the last thing I need for a project which took me envolved for the last 4 weeks.. I'm almost done. Thank you very much in advance.