I have:
dictionary = {\"foo\":12, \"bar\":2, \"jim\":4, \"bob\": 17}
I want to iterate over this dictionary, but over the values instead of the
I think the best way to do this (considering migration to Python 3) is
>>> mydict = {'foo': 12, 'bar': 2, 'jim': 4, 'bob': 17}
>>> [k for k in mydict if mydict[k] > 6]
['bob', 'foo']
The criteria for "best" is readability.
(Disclaimer: my answer is based in Alex Martelli's answer to other question https://stackoverflow.com/a/3744713/556413 and @jamylak's to this question)