0
How can I index this 3D array in Python? Why this output?
#declaration of 3d array a=[[[0]*3]*3]*3 https://code.sololearn.com/c6G38kyWflP4/?ref=app
3 Réponses
+ 5
print(a[0][1][2]) returns 6th 0 from the left.
+ 4
That's a problem of python not Sololearn.
You can try this instead
a = [[[0]*3 for i in range(3)] for j in range(3)]
a[0][1][2]=1
print(a)
https://stackoverflow.com/questions/240178/list-of-lists-changes-reflected-across-sublists-unexpectedly
0
I think there is a problem in this app. If I try:
a[0][1][2]=1
print(a)
The output is not right