I need to fill a area in a 10*10 matrix with a real number and for this i have made this code in python:
# 'x' and 'x1' are points in a surface that delimit the area
[x, x1, y, y1] = [0, 5, 0, 2]
surfaceXY = [[0]*10]*10
for i in range(x, x1):
for j in range(y, y1):
surfaceXY[i][j] = 5
for k in range(10):
for l in range(10):
print surfaceXY[k][l],
print ""
i want to output this:
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
but the code will output is:
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0
Can someone explain me why, and how is the right way to solve this problem in python?