Write a program to reverse the key and item mapping


Topic: Write a program to reverse the key and item mapping

Solution

sample_dict = {1:'Seeta',2:'Geeta',3:'Babita'}
print("The original dictionary : " + str(sample_dict)) 
sample_dict = {v:k for k, v in sample_dict.items()}
print("Inverse mapped dictionary : ", str(sample_dict))



List all Python Programs