1 Upvote

Finding the Dictionary Key with Largest & Smallest Values

Python
General Python

# Key with the largest value
max(a_dictionary, key=a_dictionary.get)

# Key with the the smallest value
min(a_dictionary, key=a_dictionary.get)

By GregHe1979 - Last Updated July 6, 2022, 10:03 a.m.

Did you find this snippet useful?

Sign up to bookmark this in your snippet library

COMMENTS
RELATED SNIPPETS
Python For Else Loop
Python
General Python

Loop

2
Top Contributors
103
100