Main problem
why the values are getting updated for every key ??
code
d = {0: [0], 1: [0, 1]}
for i in range(2, 4):
d[i] = d[i - 1]
d[i].append(i)
print(d)
output
{0: [0], 1: [0, 1, 2, 3], 2: [0, 1, 2, 3], 3: [0, 1, 2, 3]}
I want it like this in the output
{0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]}
can someone please help me understand why's this happening and the possible solutions? That would be great if you can attach the related python documentation!!