6. Printing Pretty


Have been working on def print_board and keep getting the error: name ‘row’ is not defined, have compared my code to others on the forum and can see no difference.
My code below

for i in range(5):
  board.append(["O"] * 5)

def print_board(board):
    for row in board:
        print" ".join(row)
print_board (board)


Did you create your board variable yet (it’s an empty list)? I don’t see it here.

I tested your code and it works for me.


Yes, line one is

I get run window (black background) I get a 5 x 5 table of O’s, but the error message appears from the code academy feedback. Could it be to do with indenting? Since code academy updated, tab no gives me 2 spaces, so I have been manually entering 4 spaces, is this correct?


No, I don’t think that’s the problem. I think we’re supposed to do 2-space indentation.

There are bugs within the Python courses and Codecademy is working on it.


Ok, I will ignore the error message then. I have checked all my indenting is set to 2 spaces for each indent.
Thanks for your help


You’re welcome. Sorry for the inconvenience.


While 2 spaces is fine for Python, the lesson checker may be expecting consistent 4 space indentations.


Hmm okay, I tested it with 2-spaces and it worked. Well, at least I know. Thanks @mtf.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.