Finding The Biggest Key In A Python Dictionary?


If you have a dict with string-integer mappings, you can use the max method on the dictionary's item pairs to get the largest value. 

example

d = {
   'foo': 100,
   'bar': 25,
   'baz': 360
}
print(max(k for k, v in d.items()))

Output

This will give the output −

foo

foo is largest in alphabetical order.

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 05-Mar-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements