how to copy one dictionary to another in python

import copy

dict2 = copy.deepcopy(dict1)

Here is what the above code is Doing:
1. It’s creating a new dictionary called dict2.
2. It’s copying the contents of dict1 into dict2.
3. It’s creating a new dictionary called dict3.
4. It’s copying the contents of dict2 into dict3.
5. It’s modifying the value of dict3[“foo”] to be “bar”.
6. It’s printing out the value of dict1[“foo”] to show that it hasn’t changed.
7. It’s printing out the value of dict2[“foo”] to show that it hasn’t changed.
8. It’s printing out the value of dict3[“foo”] to show that it has changed.