finding max based on key in python code example
Example 1: python find the key with max value
a_dictionary = {"a": 1, "b": 2, "c": 3}
max_key = max(a_dictionary, key=a_dictionary.get)
print(max_key)
Example 2: python get the key with the max or min value in a dictionary
key_with_max_value = max(dictionary, key=dictionary.get)
max_value = dictionary[max(dictionary, key=dictionary.get)]
max_value = max(dictionary.values())
dictionary = {"a": 1, "b": 2, "c": 3}
max(dictionary, key=dictionary.get)
--> 'c'