Swap keys for values : Iteritems : Dictionary PYTHON TUTORIALS


PYTHON TUTORIALS » Dictionary » Iteritems »

 

Swap keys for values


myDictionary = {'color':'blue', 'speed':'fast', 'number':15:'number'}

swapDictionary = {}
for key, val in myDictionary.iteritems():
    swapDictionary[val= key

print swapDictionary



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Dictionary
» Iteritems