How to copy a dictionary and only edit the copy

I set dict2 = dict1. When I edit dict2, the original dict1 also changes. How can I avoid this?

>>> dict1 = {"key1": "value1", "key2": "value2"}
>>> dict2 = dict1
>>> dict2["key2"] = "WHY?!"
>>> dict1
{'key2': 'WHY?!', 'key1': 'value1'}

← Назад к списку