1a_dictionary = {"a": 1, "b": 2, "c": 3}
2
3# get key with max value
4max_key = max(a_dictionary, key=a_dictionary.get)
5
6print(max_key)
1a_dictionary = {"a": 1, "b": 2, "c": 3}
2
3max_key = max(a_dictionary, key=a_dictionary.get)
4get key with max value
5
6
7print(max_key)
1my_dict = {'a': 5, 'b': 10, 'c': 6, 'd': 12, 'e': 7}
2max(my_dict, key=my_dict.get) # returns 'd'
1from operator import itemgetter
2
3items = [
4 {'a': 1, 'b': 99},
5 {'a': 2, 'b': 88},
6 {'a': 3, 'b': 77},
7]
8
9print(max(items, key=itemgetter('a')))
10print(max(items, key=itemgetter('b')))
1import operator
2stats = {'a':1000, 'b':3000, 'c': 100}
3max(stats.iteritems(), key=operator.itemgetter(1))[0]