+ 2
Why the output is false ❓
Why x[0][0]=1 and y[0][0] working different ❓ https://code.sololearn.com/c04t9RSj9uTS/?ref=app
6 Respostas
+ 1
no x=[[0,0,0]]*3
this is still x = [0,0,0]
then x[0][0] = 1
x then became [1,0,0]
now as x is multiplied it becomes 3 x arrays as [[1,0,0] [1,0,0] [1,0,0]]
x[0][0] is behaving like x[0][0] and x[0][0] and x[0][0]
or [[x[0][0],0,0]]*3
+ 3
It is false because
x=[[1,0,0],[1,0,0],[1,0,0]]
y=[[1,0,0],[0,0,0],[0,0,0]]
So x==y is false
+ 2
ClassHacker as Pedro H.J pointed out here is your code as we go line by line:
https://code.sololearn.com/cgZx130N6PuE/?ref=app
+ 1
check out line 12 on my code
print([[x[0][0],0,0]]*3)
0
but why x[0][0] is behaving like x[1][0] and x[2][0]