How to merge two dicts in python

d1={"A": 10, "B": 20 }
d2={"B": 30, "C": 40}

d3={**d1, **d2}
print(d3)

# result is {'A': 10, 'B': 30, 'C': 40}

notice that the value of key B is 30.