0

What's the defference between these codes that makes different outputs?

_In this python code: A=[[0]*8]*8 _and this other one: A=[] for h in range(8): b=[] for i in range(8): b.append(0) A.append(b) _what's the difference, that if I change something ( for example A[1][5]=6 ) , I'll have different outputs.

1st Dec 2016, 6:05 PM
Kiarash Majdi
Kiarash Majdi - avatar
1 Réponse
0
I think that in the first option you will get simply an arrey of 64 ints. In the second option the A.append(b) will create a list item from type arrey...and nit and not an Int. (a list within a list)
12th Dec 2016, 11:27 PM
Idan