Write a program to reverse dictionary key order


Topic: Write a program to reverse dictionary key order

Solution

sample_dict = {1:'Hi',2:'Hello',3:'Hey'}
print("The original dictionary : " + str(sample_dict)) 
res = dict(reversed(list(sample_dict.items()))) 
print("The reversed order dictionary : " + str(res))



List all Python Programs