I am trying to append 5 cells to "completeArray" while with each call of the function incrementing the originArray[x][1] by 1 increment. however the answer is always a duplicate!
originArray = [[0,0],[0,1],[1,0],[2,0],[3,0]]
completeArray = []
def myFuncTest():
tempArray = []
for cell in originArray:
tempArray.append(cell)
completeArray.extend(tempArray)
tempArray = []
for cell in originArray:
cell[1] = cell[1]+1
print("++--",originArray)
return completeArray
print("----",myFuncTest())
print("----",myFuncTest())
The result is
++-- [[0, 1], [0, 2], [1, 1], [2, 1], [3, 1]]
---- [[0, 1], [0, 2], [1, 1], [2, 1], [3, 1]]
++-- [[0, 2], [0, 3], [1, 2], [2, 2], [3, 2]]
---- [[0, 2], [0, 3], [1, 2], [2, 2], [3, 2], [0, 2], [0, 3], [1, 2], [2, 2], [3, 2]]
The correct result of "completeArray" should be as follows
[[0, 1], [0, 2], [1, 1], [2, 1], [3, 1], [0, 2], [0, 3], [1, 2], [2, 2], [3, 2]]