I'm trying to create a list containing multiple lists filled with the same values this way:
l1 = [[False] * n] * m
There are no any errors and at first glance it looks like valid lists of lists (print(l1) for n=m=3 : [[False,False,False],[False,False,False],[False,False,False]]
)
But when I tried l1[0][0] = True
I got a strange behaviour - list has turned into [[True,False,False],[True,False,False],[True,False,False]]
.
So, why did such list initialization results to it? And what should I do to create a list properly?