I have a list of dictionaries that looks like the following:
d = [{'first':'jason','color':'green','age':22},
{'first':'josh','color':'red','age':22},
{'first':'chris','color':'blue','age':21}
]
I want to create a dictionary that is a subset of the previous dictionaries.
Something that looks like:
newD = {'jason':22, 'josh':22, 'chris':21}
The following does the trick:
first = [k['first'] for k in d]
age = [k['age'] for k in d]
newD = dict(zip(first, age))
But is there a more Pythonic/cleaner way to do this?