k = 3
x = [0] * k
y = [[0] * k] * k
z = [[0] * k for i in range(k)]
print(x, y, z)
x[0] = 1
x[1] = 2
y[0][0] = 1
y[0][1] = 2
z[0][0] = 1
z[0][1] = 2
print(x, y, z)
Item 24: List
Posted by Logan Chien
k = 3
x = [0] * k
y = [[0] * k] * k
z = [[0] * k for i in range(k)]
print(x, y, z)
x[0] = 1
x[1] = 2
y[0][0] = 1
y[0][1] = 2
z[0][0] = 1
z[0][1] = 2
print(x, y, z)