python get the key with the max or min value in a dictionary

a_dictionary = {"a": 1, "b": 2, "c": 3}

# get key with max value
max_key = max(a_dictionary, key=a_dictionary.get)

print(max_key)

Here is what the above code is Doing:
1. We create a dictionary with three key-value pairs.
2. We use the max function to get the key with the maximum value.
3. We pass the key function to the max function.
4. The key function returns the value of the key-value pair.
5. The max function returns the key with the maximum value.