Finding the max value in a dictionary finds either the key associated with the maximum value or the value itself. For example, in {"a": 1, "b": 2, "c": 3}, the key of the largest value is "c" and the largest value is 3.
USE max() AND dict.get TO FIND THE KEY WITH THE MAX VALUE IN A DICTIONARY
Call max(iterable, key=dict.get) with the same dictionary as both iterable and dict to find the key paired with the max value.
>>> a_dict = {"a": 1, "b": 2, "c": 3}
>>> max(a_dict, key=a_dict.get)
'c'
>>>
USE max() AND dict.values() TO FIND THE MAX VALUE IN A DICTIONARY
>>> max(a_dict.values()) # a_dict.values() returns a list 3 >>>
This article is contributed by Prakash. If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.