inversing the keys and values in a dictionary python -


this question asked wondering if there way solve problem without using .iteritems() or .items() ??

https://stackoverflow.com/a/8305541/3975231

i've tried myself know can't iter on values in dictionary

dictionary = {} key in d:     = key     dictionary[key] in d:         b = dictionary[key]         dictionary[b] = return dictionary 

and this:

dictionary = {} key in d:     = key     d[a] = return dictionary 

would appreciate

in second example you're not adding dictionary. should be:

dictionary = {} key in d:     dictionary[d[key]] = key  # no need save key in new variable return dictionary      

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -