The function gboard is suppose to return a nested list in column major order. I have gotten it to do this, but I am not sure of how to set each value in the list equal to 0 (or the variable I set equal to 0 in another function called constants.dead.) If anyone has any idea of how I could do this I would appreciate the help.
def gboard(height, width):
""" Returns: Nested list in column-major order representing a game board. All the cells in the board are in the set to 0.
Parameter height: number of rows in the board
Parameter width: number of columns in the board
Precondition: height and width are positive ints
"""
list = []
for y in range(width):
list.append([])
for x in range(height):
list[y].append(x)
return list
The output of the function for example is this:
>>> gboard(4,3)
[[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]]
But I would rather it be:
>>> gboard(4,3)
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
board = [width*[0] for _ in range(height)], and please do nut uselistas variable name...listbut i am still confused as to whatboardis for you and where you get 19 from.return board, ...added as an answer.