Q. Write a Python script to concatenate the following dictionaries to create a new one:

 

d1 = {‘A’: 1, ‘B’: 2, ‘C’: 3}

d2 = {‘D’: 4}

 

Output should be:

{‘A’: 1, ‘B’: 2, ‘C’: 3, ‘D’: 4}

 

Answer =

 



d1 = {"A": 1, "B": 2, "C": 3}
d2 = {"D": 4}

d1.update(d2)
print(d1)

1 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post