<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi, <div><br></div><div>I'm trying to create a 3D grid, so I'm using a list of list of lists. </div><div>However, if I try to make a change to one value, eg</div><div>grid[0][1][2] = 3, </div><div>It doesn't just change list[0], it change the 2nd element in the 1st list of every list? </div><div>I think it's because I've copied lists to get the grid, but could you help me fix this? </div><div><br></div><div>This is my code, that takes an x,y,z value from user. </div><div><br></div><div><div>self.grid_x = x</div><div>self.grid_y = y</div><div>self.grid_z = z</div><div><br></div><div>self.grid = []</div><div>self.grid2D = []</div><div><br></div><div>for i in range(self.grid_y):</div><div> row = [0]*x</div><div> self.grid2D.append(row)</div><div><br></div><div>for k in range(z):</div><div> self.grid.append(self.grid2D) #Creates list of x by y grids</div></div><div><br></div><div>Thank you so much</div><div>Corrine</div> </div></body>
</html>