They might not have bothered to tell you to include it in 7/19, because for the purposes of the exercises so far your board has been square (5 x 5). Assuming you’ve followed the instructions, your number of rows given by
len(board) is equal to the number of columns, given by
I think perhaps Codecademy simply made an assumption, and neglected to point out why they made the change they did to the code in 8/19. Basically, using
board allows you to accommodate a non-square board if you choose but the exercises instruct you to use 5 x 5.
Yes, they did. However, your code shouldn’t assume that the board will always be square, which brings us to…
Think about how you’re generating, and storing, the layout of the board. It’s basically a list of lists.
board, is a list generated by the loop:
for x in range(0, 5):
board.append(["0"] * 5)
In that code, the
["0"] * 5 bit gives you a row that’s 5 items long - i.e. we create 5 columns. If we used 7 instead of 5, we’d no longer get a square board from the loop above.
The number of rows you make is based on the upper value you give to the
So, let’s say we do this:
for x in range(0, 10):
board.append(["0"] * 7)
board will contain
["0", "0", "0", "0", "0", "0", "0"], or one complete row. If you know the length of the row (i.e. the length of
board) you know the number of columns. Since each item in
board itself is a complete row, if you know the length of
board you know the number of rows.
Does that make it any clearer?