Feb-01-2023, 11:33 PM
I'm a beginner in python and I can't understand why this doesn't work like seriously, i really tried. You can see the result of the function on the left, it modify a whole column, i only want to modify one 0 here. Furthermore, the blank matrix (SiteVierge2d) is modified, why ? I made a copy.
My code:
Thx for the help and sorry if this has already been answered somewhere because I didn't find it
My code:
SiteVierge2d=[[0]*(8)]*(5) #Le site vierge def batiment2d(S,b,Origin,T): M=S[:] x0,y0=Origin l,k=T for i in range(x0,x0+l): for j in range(y0,y0+k): M[i][j]=b return M print(batiment2d(SiteVierge2d,'t',(1,1),(2,1)))My goal is to make a function that modify the matrix in a form of a rectangle of 'b' (instead of 0). The origin point of the rectangle is x0,y0 and the length and wideness is l,k (but here in the image, everything is just 1), here is what i mean :
Thx for the help and sorry if this has already been answered somewhere because I didn't find it