You can merge two dictionaries in Python with these simple steps:
1. Iteration over the second dictionary, for every key-value pair of the second dictionary you should see if the key exists in the first dictionary.
2.If key is same in both dictionaries, then add the sum of both values.
3.If the given key is unique add it to the combined dictionary.
Example:
dict1 = {‘keya': 100, 'keyb': 200, 'keyc': 300}
dict2 = {'b': 150, 'c': 250, 'd': 400}
combined_dict = dict1.copy()
for key, value in dict2.items():
if key in combined_dict:
combined_dict[key] += value
else:
combined_dict[key] = value
print(combined_dict)