How do you merge two dictionaries in a single expression?

dict_a = {1: 'Ram', 2: "Krishna", 3:"Paramhansh"}
dict_b  = {2: 'Swami', 4: "Vivek"}

merged_dict = {**dict_a, **dict_b}
print(merged_dict)

Output:

{1: 'Ram', 2: 'Swami', 3: 'Paramhansh', 4: 'Vivek'}

Leave a Reply

Your email address will not be published. Required fields are marked *