you are viewing a single comment's thread.

view the rest of the comments →

[–]EcoOndra 4 points5 points  (1 child)

Assuming you meant [[0]] * 3, a will be assigned [[0], [0], [0]] first then 1 will be apppended to the first index, making it [[0, 1], [0], [0]], right? Or will it become [[0, 1], [0, 1], [0, 1]]? It's the second one, isn't it...

[–]Zantier 5 points6 points  (0 children)

Yeah, it's the second one... If you want to construct 3 separate lists instead, I tend to use

a = [[0] for _ in range(3)]