I have a list with a bunch of dictionaries that I am trying to combine into one
Looks like this...
[{'name':'name', 'value':'john'}, {'name':'sex', 'value':'male'}, {'name':'color', 'value':'blue'}, {'name':'car', 'value':'toyota'}, {'name':'job', 'value':'cashier'}]
I'm trying to combine them all into one dictionary so that the name value is the key and the value is the value. Right now I'm doing something like this and it works fine but I know there is an easier way
keys = []
vals = []
for item in a:
if item['name']:
keys.append(item['name'])
if item['value']:
vals.append(item['value'])
md = dict(zip(keys,vals))
Any guidance would be appreciated... thank you