I just started learning python. I come from C++/Java background. To understand two dimensional arrays. I have written the following snippet
x = [[0]*3]*3
for i in range(0,3):
for j in range(0,3):
x[i][j] = i+j
for i in range(0,3):
for j in range(0,3):
print x[i][j],
print ""
Why is this program printing
2 3 4
2 3 4
2 3 4
instead of my expectation
0 1 2
1 2 3
2 3 4
I thought about the reason for this and I am not able to conclude anything. Is this something to do with reference variables?