Home>

We become indebted to.
I am not sure how to use a two-dimensional array and would appreciate it if you could give me some advice.
I want to store sub_list in a place called A_LIST in python.
A_list [m] = sub_list on line 10 of the program
When that was executed, I thought that the value of sub_list would be stored only in the mth element of A_list.
Looking at the result, all the elements of A_list have the value of sub_list.
Is there a solution here?

m = 0
sub_list = [0, "dummy"]
A_list = []
while m<10:
    A_list.insert (m, 0)
    sub_list [0] = m
    print ("")
    print (sub_list)
    A_list [m] = sub_list
    print (m)
    print (A_list)
    m = m + 1
[0,'dummy']
0
[[0,'dummy']]
[1,'dummy']
1
[[1,'dummy'], [1,'dummy']]
[2,'dummy']
2
[[2,'dummy'], [2,'dummy'], [2,'dummy']]
[3,'dummy']
3
[[3,'dummy'], [3,'dummy'], [3,'dummy'], [3,'dummy']]
[4,'dummy']
Four
[[4,'dummy'], [4,'dummy'], [4,'dummy'], [4,'dummy'], [4,'dummy']]
[5,'dummy']
Five
[[5,'dummy'], [5,'dummy'], [5,'dummy'], [5,'dummy'], [5,'dummy'], [5,'dummy']]
[6,'dummy']
6
[[6,'dummy'], [6,'dummy'], [6,'dummy'], [6,'dummy'], [6,'dummy'], [6,'dummy'], [ 6,'dummy']]
[7,'dummy']
7
[[7,'dummy'], [7,'dummy'], [7,'dummy'], [7,'dummy'], [7,'dummy'], [7,'dummy'], [ 7,'dummy'], [7,'dummy']]
[8,'dummy']
8
[[8,'dummy'], [8,'dummy'], [8,'dummy'], [8,'dummy'], [8,'dummy'], [8,'dummy'], [ 8,'dummy'], [8,'dummy'], [8,'dummy']]
[9,'dummy']
9
[[9,'dummy'], [9,'dummy'], [9,'dummy'], [9,'dummy'], [9,'dummy'], [9,'dummy'], [ 9,'dummy'], [9,'dummy'], [9,'dummy'], [9,'dummy']]

The data I want to output as the final result is as follows.

[[0,'dummy'], [1,'dummy'], [2,'dummy'], [3,'dummy'], [4,'dummy'], [5,'dummy'], [ 6,'dummy'], [7,'dummy'], [8,'dummy'], [9,'dummy']]