Skip to content

Instantly share code, notes, and snippets.

@brettfreer
Last active July 6, 2016 10:43
Show Gist options
  • Save brettfreer/4e0751568a06527626e3005e2585351e to your computer and use it in GitHub Desktop.
Save brettfreer/4e0751568a06527626e3005e2585351e to your computer and use it in GitHub Desktop.
Return the key with the maximum value in a dictionary
import operator
def max_value(m):
return max(m.iteritems(), key=operator.itemgetter(1))[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment