+ 1
What's the logic behind this guys
I really don't understand the logic behind this, could someone explain this to me https://code.sololearn.com/cu6H2dd1xTI9/?ref=app
2 ответов
+ 6
a = [[]]*3
a[0].append(3)
print(a)
1. 3 multiplies the empty lists inside the 2d 3 times this it will look like this.
[[],[],[]]
2. Then you want to append the 3 at the index 0 of each list in the 2d list.
And it will be.
[[3],[3],[3]]
+ 2
Thank you so much bro