0

How?Why?Who can explain this to me?

a = [[0]*2]*2 print (a) a[0][0]=5 print (a) b = [[0,0],[0,0]] b[0][0]=6 print (b)

22nd May 2019, 10:29 AM
Արմեն Գևորգյան
Արմեն Գևորգյան - avatar
2 Respostas
+ 1
[[5,0], [5,0]] -> [[5,0]]*2 This is duplication, as such when multiplying strings. print(“abc”*2) “abcabc”
22nd May 2019, 12:18 PM
Choe
Choe - avatar
0
I think I got it. Thank you)
23rd May 2019, 8:59 AM
Արմեն Գևորգյան
Արմեն Գևորգյան - avatar