I have data of the following type:
foos = [{'bar': [{'baz': 1}, {'baz': 2}]}, {'bar': [{'baz': 3}, {'baz': 4}]}, {'bar': [{'baz': 5}, {'baz': 6}]}]
I need a list comprehension that will give:
[1, 2, 3, 4, 5, 6]
I'm not quite sure how to do this. This sorting works:
>>> [[bar['baz'] for bar in foo['bar']] for foo in foos] [[1, 2], [3, 4], [5, 6]]
but I want the results to be a flattened list.
source share