Merge Two Dictionaries in Python

Python Program to Merge Two Dictionaries

# Python Program to merge two dictionaries

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

# Merge dictionary
dict_2.update(dict_1)

# Output
print("Merged dictionary is: ", dict_2)

Output:

Merged dictionary is:  {'c': 3, 'd': 4, 'a': 1, 'b': 2}

About The Author

Leave a Reply