Declare the list with Python
list_a = [[0,0,0], [0,0,0], [0,0,0]....[0,0,0]]
I want to make a list like this.
The way I thought of it is
list_a = [[0,0,0]] * 100
If you create it like this, the problem is
list_a[0][1] = 1
If this is the case
list_a = [[0, 1, 0], [0,1,0], [0,1,0]....[0,1,0]]
There was a problem with all the index values changing at once.
For me,
list_a = [[0,1,0], [0,0,0], .... [0,0,0]]
I just wanted to do this.
How can I make 100 lists inside the list that work the way I want?
python
It's a self-answer.
list_a = [ [0,0,0] for _ in range(3) ]
Do it like this.
© 2025 OneMinuteCode. All rights reserved.