I was working on some problem and came across this.
Python code
row=[]
col=[]
init=[-1,-1]
Now I append this init
to row
and col
.
row.append(init)
row.append(init)
col.append(init)
col.append(init)
Therefore row = [[-1,-1],[-1,-1]]
and col = [[-1,-1],[-1,-1]]
Now when i change init[0] = 9
my row
and col
becomes
row = [[9,-1],[9,-1]]
and col = [[9,-1],[9,-1]]