how to get the minimum value in a dictionary python code example
Example 1: python get the key with the max or min value in a dictionary
# Basic syntax:
key_with_max_value = max(dictionary, key=dictionary.get)
# Note, to get the max value itself, you can do either of the following:
max_value = dictionary[max(dictionary, key=dictionary.get)]
max_value = max(dictionary.values())
# Example usage:
dictionary = {"a": 1, "b": 2, "c": 3}
max(dictionary, key=dictionary.get)
--> 'c'
Example 2: how to search dictionaryfor lowest value
min(d, key=d.get)