Let's say I have two 2D lists, as shown below:
[[('a', '1'), ('a', '12'), ('a', '3')], [('b', '21'), ('b', '31')], [ ('c', '11')]]
The output I want to achieve is:
Output_list=[['1','12','3'], ['21','31'], ['11']]
The main difficulty here is that I want to achieve the result with one list comprehension
.
One of my attempts:
print [a for innerList in fin_list1 for a,b in innerList]
Output:
['1', '12', '3', '21', '31', '11']
But, as you can see, although I successfully retrieved the second element of each tuple, I could not save my internal list structure.