Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Second largest value in a Python Dictionary

  • Last Updated : 20 Dec, 2018

In this problem we will find the second largest value in the given Dictionary.
Examples:

Input :  {'one':5, 'two':1, 'three':6, 'four':10}
Output :  Second largest value of the dictionary is 6

Input :   {1: 'Geeks', 'name': 'For', 3: 'Geeks'}
Output :  Second largest value of the dictionary is Geeks




dictionary = {1: 'Geeks', 'name': 'For', 3: 'Geeks'}
val = list(dictionary.values())
val.sort()
res = val[-2]
print(res)
Output:
Geeks

Time Complexity : O(n Log n)

Please refer below post for more methods :

Python program to find second maximum value in Dictionary

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!