how to copy a dictionary in python 3.1 and edit ONLY the copy
- by MadSc13ntist
can someone please explain this to me??? this doesn't make any sense to me....
I copy a dictionary into another and edit the second and both are changed????
ActivePython 3.1.0.1 (ActiveState Software Inc.) based on
Python 3.1 (r31:73572, Jun 28 2009, 19:55:39) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
dict1 = {"key1":"value1", "key2":"value2"}
dict2 = dict1
dict2
{'key2': 'value2', 'key1': 'value1'}
dict2["key2"] = "WHY?!?!?!!?!?!?!"
dict1
{'key2': 'WHY?!?!?!!?!?!?!', 'key1': 'value1'}