Last active
August 29, 2015 13:56
-
-
Save vsinha/8902932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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