7. Hide... Why board instead of board_in?


I don’t understand why I couldn’t use board-in as input to make this successfully work. I am not sure why the argument board works instead?


board-in is not a valid name for a variable because the - character cannot be part of a variable’s name. The instructions ask you to use the name board_in, which contains an underscore, and that is permitted.


because your code looks like
def print _board(board):
for row in board:
print " ".join(row)
def random_row(board):
but if
def print _board(board_in):
for row in board:
print " ".join(row)
def random_row(board_in):
etc. will work



If your function header is as follows …

def print_board(board_in):

… then instead of using this for loop header inside the function …

  for row in board:

… it should be this …

  for row in board_in:

The function parameter should be accessed rather than the global board object directly. So if you change the name of the function parameter, change the code inside the function to use that parameter.


This topic was automatically closed after 2 days. New replies are no longer allowed.