I would like to create something like this:
lst = [[None, None], [None, None], [None, None]]
using list comprehensions. However, whatever I try, I find that performing lst[0][0] = True
does not have the desired effect. Instead of making the list lst = [[True, None], [None, None], [None, None]]
, it changes it to lst = [[True, None], [True, None], [True, None]]
.
Here's the different ways that I've tried creating my list comprehension:
lst = [[None] * 2] * 3
lst = [copy.deepcopy([None] * 2)] * 3
lst = [list([None] * 2])[::]] * 3