Skip to content

Instantly share code, notes, and snippets.

@vsinha
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsinha/8902932 to your computer and use it in GitHub Desktop.
Save vsinha/8902932 to your computer and use it in GitHub Desktop.
import operator
# create a dict
d = dict()
d[0] = 10
d[1] = 20
d[2] = 20
# find the max value
maxValue = max(d)
# find all keys that match the max value
maxValues = [key for key in d.keys() if d[key]==maxValue]
# the first one in this list is what you're looking for
print maxValues[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment