Write a Python program to combine two dictionary by adding values for common keys


Topic: Write a Python program to combine two dictionary by adding values for common keys

Solution

dict1 = {'a': 12, 'for': 25, 'c': 9} 
dict2 = {'Geeks': 100, 'geek': 200, 'for': 300} 
for key in dict2: 
    if key in dict1: 
        dict2[key] = dict2[key] + dict1[key] 
    else: 
        pass



List all Python Programs