How can I create another dictionary using the keys of another dictionary, and an array of values?
I thought about doing this:
zipped = zip(theExistingDict.keys(), arrayOfValues)
myNewDict = dict(zipped)
However, this doesn't quite work, each value from arrayOfValues
are paired with an arbitrary key in the resulting dictionary. I don't have any control over which element from arrayOfValues
is paired with which key in theExistingDict.keys()
.
theExistingDict
looks like this:
{u'actual bitrate': 4, u'Suggested Bitrate': 3, u'title': 2, u'id': 1, u'game slot': 0}
arrayOfValues
looks like this:
1.0, u'GOLD_Spider Solitaire', u'Spider\\nSolitaire', 120000.0, 120000.0
So: I would like arrayOfValues[0]
to map to game slot
(because in the dictionary it has value 0).
Is there an easy and elegant way to do this?