I have a nested dict but when I update one dict all the others also are updated. How can I avoid that? Below is an example:
a = {}
b = {'d': [], 'e': []}
a[1] = b
a[2] = b
a[1]['e'].append([1, 2, 3])
# result: {1: {'e': [[1, 2, 3]], 'd': []}, 2: {'e': [[1, 2, 3]], 'd': []}}
Here 'e'
is updated on both 1 and 2 but I want just 1 to be updated:
{1: {'e': [[1, 2, 3]], 'd': []}, 2: {'e': [], 'd': []}}