I have the following code to create a dictionary whose elements are lists from another dictionary:
olddict={'Fiesta': {'key':'Ford'},'Golf': {'key':'Volkswagen'}, 'Bora': {'key':'Volkswagen'} }
newdict = {}
for key, value in olddict.items():
newkey = value['key']
if newkey in newdict:
newdict[newkey].append(key)
else:
newdict[newkey] = [key]
The code works fine, but seems utterly non-pythonic. Maybe I am a bit tired, but a one-line solution would be great...