I'm trying to create a list that holds this exact format: [[2],[2],[2],[2],[2],[2],[2],[2],[2],[2]]
and when list[3][0] = 9
is called, the list becomes [[2],[9],[2],[9],[2],[9],[2],[9],[2],[9]]
How do I create the list in the first place that will allow me to change these many elements with only one line?
>>> L = [[2], [2]] * 5
>>> L
[[2], [2], [2], [2], [2], [2], [2], [2], [2], [2]]
>>> L[3][0] = 9
>>> L
[[2], [9], [2], [9], [2], [9], [2], [9], [2], [9]]
This is because the same two lists are repeated over and over
>>> [id(x) for x in L]
[140053788793352, 140053788793288, 140053788793352, 140053788793288, 140053788793352, 140053788793288, 140053788793352, 140053788793288, 140053788793352, 140053788793288]