Skip to content
Related Articles

Related Articles

Second largest value in a Python Dictionary

Improve Article
Save Article
  • Last Updated : 20 Dec, 2018
Improve Article
Save Article

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
Related Articles

Start Your Coding Journey Now!