how do i return first biggest key value from dictionary in python code example
Example 1: python max key dictionary key getter
from operator import itemgetter
items = [
{'a': 1, 'b': 99},
{'a': 2, 'b': 88},
{'a': 3, 'b': 77},
]
print(max(items, key=itemgetter('a')))
print(max(items, key=itemgetter('b')))
Example 2: max element in dictionary python
import operator
stats = {'a':1000, 'b':3000, 'c': 100}
max(stats.iteritems(), key=operator.itemgetter(1))[0]