Q. Write a Python program to find the highest 2 values in a dictionary.
Answer :-
dic = eval(input( "Enter a dicvtionary :-"))
lst = list( dic.values() )
print(lst)
large = lst [ 0 ]
sec = lst[ 0 ]
for i in lst :
if large <= i :
large = i
elif sec < i :
sec = i
print("Highest two values :-", large , sec)
Output :-
Enter a dicvtionary :-{"Path" : 10 , "walla" : 27 , "portal" : 13 , "express" : 4 ,"python" : 15 }
[10, 27, 13, 4, 15]
Highest two values :- 27 15
>>>
invalid syntax
ReplyDeleteNo, Answer is correct.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )