python merge dict

dict1 = {'color': 'blue', 'shape': 'square'}
dict2 = {'color': 'red', 'edges': 4}

dict1.update(dict2) #if a key exists in both, it takes the value of the second dict
# dict1 = {'color': 'red', 'shape': 'square', 'edges': 4}
# dict2 is left unchanged

Here is what the above code is Doing:
1. dict1 = {‘color’: ‘blue’, ‘shape’: ‘square’}
2. dict2 = {‘color’: ‘red’, ‘edges’: 4}
3. dict1.update(dict2)
4. dict1 = {‘color’: ‘red’, ‘shape’: ‘square’, ‘edges’: 4}
5. dict2 = {‘color’: ‘red’, ‘edges’: 4}