This is my line of code:
>>> table = [[0] * 3] * 3
>>> table
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> table[1][1] = 99
and it yields the below result:
>>> table
[[0, 99, 0], [0, 99, 0], [0, 99, 0]]
Then, there is this below line of code:
>>> tab = [[0 for i in range(3)] for j in range(3)]
>>> tab
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> tab[1][1] = 99
But this yields a different result:
>>> tab
[[0, 0, 0], [0, 99, 0], [0, 0, 0]]
Both are the same lists. Same assignment. But how come they yield different results? Someone please help me understand.