Python Program to Merge Two Dictionaries (Using copy() and update())

bookmark

dict_1 = {1: 'a', 2: 'b'}
dict_2 = {2: 'c', 4: 'd'}

dict_3 = dict_2.copy()
dict_3.update(dict_1)

print(dict_3)

 

Output

{2: 'b', 4: 'd', 1: 'a'}