my_list = [0] * 3
my_list[0] = 1
outputs to [1, 0, 0]
my_2ndlist = [[0] * 3] * 3
my_2ndlist[1][1] = 5
outputs to [[0, 5, 0], [0, 5, 0], [0, 5, 0]]
I think I know that x = 1 y = 1 makes x and y point to the same location in memory. So I get the sense of the second output, even if it's not what I think you would expect. But then I don't fully get the first as I would expect it's still 3 times a reference to the same memory location.
Any explanation that could help me understand better? Thank you.