I create two dictionaries: d1 and d2 and put them in a list c.
d1 = {'col1': [1, 2], 'col2': [3, 4]}
d2 = {'col1': [3, 6], 'col2': [5, 6]}
c=[d1,d2]
When I change an value in list c:
c[0]["col1"][0]=3
c
[{'col1': [3, 2], 'col2': [3, 4]}, {'col1': [3, 6], 'col2': [5, 6]}]
I surprisingly find that the specific value in original dictionary d1 also changed:
d1
{'col1': [3, 2], 'col2': [3, 4]}
Can anyone explain this to me? Why does d1 change together when I only try to modify values in list c?
So can I understand it this way that once I try to modify such a list, its original element (could be a dictionary, a list, or even a dataframe) will change at the same time?