a_dictionary = {"a": 1, "b": 2, "c": 3}
max_key = max(a_dictionary, key=a_dictionary.get)
get key with max value
print(max_key)
ages = {'Matt' : 30, 'Katie': 29, 'Nik': 31, 'Jack': 43}
#get the max value in Python dict
max_value = max(ages.values())
print(max_value)
#get the key for a dicts max value
max_key = max(ages, key=ages.get)
print(max_key)
from collections import Counter
# Initial Dictionary
my_dict = {'t': 3, 'u': 4, 't': 6, 'o': 5, 'r': 21}
k = Counter(my_dict)
# Finding 3 highest values
high = k.most_common(3)
print("Dictionary with 3 highest values:")
print("Keys: Values")
for i in high:
print(i[0]," :",i[1]," ")
>>> sorted(my_dict, key=my_dict.get, reverse=True)[:3]
['K', 'B', 'A']