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


#1

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?


#2

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.


#3

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


#4

@thefriday13,

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.


#5

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