Q. Given a dictionary with 5 student names and their marks. write a program that prints the dictionary contents in the ascending order of marks.
Answer :-
dic = {'Path': 98, 'Walla': 85, 'Python': 86, 'Express': 55, "Portal": 69}
new = {}
lst = list(dic.values())
lst.sort()
for i in lst :
for j in dic :
if dic [j] == i :
new [j] = i
print(new)
Output :-
{'Express': 55, 'Portal': 69, 'Walla': 85, 'Python': 86, 'Path': 98}
>>>
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )