When you create an array like this:
masks=[ [0]*3 ]*4
You actually create an array of 4 elements that has 4 references to the same element. It's easy to check this way.
masks=[ [0]*3 ]*4 print(masks) print(id(masks[0])) print(id(masks[1])) print(id(masks[2]))
Here is the result:
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] 4567441352 4567441352 4567441352
Alternatively, you can create an array like this:
funcdata=[['11'], ['12'], ['13'], ['14'], ['15'], ['16']] masks=[ [0]*3 for x in range(0,4)] print(masks) print(id(masks[0])) print(id(masks[1])) print(id(masks[2])) masks[0][0]=funcdata[0][0] print(masks)
The result will be:
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] 4567408328 4568289736 4567486856 [['11', 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]