11. Write a program to sort a dictionary's keys using Bubble ...

文章推薦指數: 80 %
投票人數:10人

11 . Write a program to sort a dictionary's keys using Bubble sort and produce the sorted keys as a list. Ans: Code: a = eval(input("Enter a dictionary: ...  ALLPOSTSSearch11.Writeaprogramtosortadictionary'skeysusingBubblesortandproducethesortedkeysas...11.Writeaprogramtosortadictionary'skeysusingBubblesortandproducethesortedkeysasalist.Ans:Code:a=eval(input("Enteradictionary:"))b=a.keys()c=[]foriinb:c.append(i)foriinrange(len(c)):forjinrange(len(c)-i-1):ifc[j]>c[j+1]:c[j],c[j+1]=c[j+1],c[j]print(c)0commentsPostnotmarkedasliked 



請為這篇文章評分?