I've never worked with 2D or 3D arrays before but i'm trying to make a maze. In my snippet, squares is a list with each instance of a cell (so in a 3x4 maze, there would be 12 instances in squares) I am then trying to append to row, a list of all the squares in a row, so row[0] would contain the first four square instances, row[1] would be the next four, etc. the row[x].append(squares[y+z]) throws the IndexError, i'm guessing it's the row[x] part, but i'm not sure what to do to fix it. I tried using extend instead of append.
numberOfRows = 3
numberOfColumns = 4
z = 0
for x in range(numberOfRows):
for y in range(numberOfColumns):
row[x].append(squares[y+z])
z += 4
rowdefined? You need to give us enough code to actually see it fail. Meanwhile, ave you verified thatsquares[y+z]is not throwing theIndexError? (You can add another line that just sayssquares[y+z]above theappendline and see if that throws.)