Is there any way to keep in a dict values references to elements of a list, and modify the list via the dict?
a = [1, 2]
b = [11, 22]
d = {k: v for k, v in zip(a, b)}
d[1] = 33
print b, d
The output is of the 2nd print:
[11, 22] {1: 33, 2: 22}
While I would like:
[33, 22] {1: 33, 2: 22}
I suspect both the dictionary creator and the modification are not correct...
In C it would be possible to keep the pointers in the dictionary and modify the value via the *
operator.
Anything similar in python or any other pythonic way to achieve this?