Q. Write a Python program to sort a dictionary by key.

 

Answer =

 

dic = eval(input("Enter dictionary :- "))
newdic = {}
lst = list(dic.keys())
lst.sort()
for i in lst :
    newdic [ i ] = dic[ i ]

print(newdic)


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post