The key should work with dict elements (i.e. key-value pairs). Then, using the second element of the element as the max key (as opposed to the dict key), you can easily extract the highest value and the key associated with it.
mydict = {'A':4,'B':10,'C':0,'D':87} >>> max(mydict.items(), key=lambda k: k[1]) ('D', 87) >>> min(mydict.items(), key=lambda k: k[1]) ('C', 0)
source share