I am defining a nested list like this x = [[None] *2] * 3
which looks like this:
[[None, None], [None, None], [None, None]]
and want to assign a value to one element, for example, a 2:
[[2, None], [None, None], [None, None]]
I thought this would work as indexing the first element of the outer list and the first element of the inner list, as x[0][0] = 2
However, the output of this is [[2, None], [2, None], [2, None]]
Could anyone please explain why this happens and how to assign a single element?
1