Write a program to replace dictionary value from other dictionary and print it


Topic: Write a program to replace dictionary value from other dictionary and print it

Solution

test_dict = {"Gfg" : 5, "is" : 8, "Best" : 10, "for" : 8, "Geeks" : 9} 
  
print("The original dictionary is : " + str(test_dict)) 
  
updict = {"Gfg"  : 10, "Best" : 17} 
d={}
for key in test_dict.keys():
     if key in updict:
        d.update({key:updict[key]})
     else:
        d.update({key:test_dict[key]})
print(d)       



List all Python Programs