Answers for "how to find the highest number in a dictionary python"

3

python how to find the highest number in a dictionary

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)
Posted by: Guest on June-05-2020
0

find the highest 3 values in a dictionary.

>>> sorted(my_dict, key=my_dict.get, reverse=True)[:3]
['K', 'B', 'A']
Posted by: Guest on July-30-2020

Code answers related to "how to find the highest number in a dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language