When I enter t=[[False]*2]*2
, I get the list [[False, False], [False, False]]
. But when I enter t[0][0] = True
, t[1][0]
also changes to True
, leaving me with [[True, False], [True, False]]
. I only want [[True, False], [False, False]]
. As a second option, I could assign t=[[False]*2, [False]*2]
and then changing t[0][0] = True
gets me what I want ([[True, False], [False, False]]
), but my real list is a lot bigger than that, so I would rather not use option 2. I figured that this was a similar issue to cloning versus copying with lists, so I tried:
([[False]*2])*2
([False]*2)*2
[[False]*2][:]*2
t = [False]*2
t = t*2
list([False]*2)*2
list([[False]*2])*2
[list([False]*2)]*2
. None of these worked. Is there any way to do this without importing any package?