Code: (Python3)
l = [[[False,False]]*3]*3
l[0][0][0] = True
print(l)
Output:
[[[True, False], [True, False], [True, False]], [[True, False], [True, False], [True, False]], [[True, False], [True, False], [True, False]]]
I just cant figure out why the second line of code changes every single first element instead of just l[0][0][0]. i feel like im missing something really obvious. if anybody could shed some light that would be great. Thanks :)