Custom Print - Board rows print correctly but submission not accepted


#1



5. Custom Print


Oops, try again. It looks like you function didn't print out the correct response!


The activity should accept my code because the console oard prints all 5 rows properly but I still get the error/


board = []
for i in range(0,5):
   board.append(["0"]*5)

def print_board(board):
    for row in board:
        print row

print_board(board)


Result:
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
None


#2

Is there any hint as to the join method?

print ' '.join(row)

#3

I saw .join used in some other chats, but didn't understand why. I just tried your suggestion but got the same answer.

Here are the instructions for reference:

First, delete your existing print statement.
Then, define a function named print_board with a single argument, board.
Inside the function, write a for loop to iterates through each row in board and print it to the screen.
Call your function with board to make sure it works.

The goal is "Let's set up a for loop to go through each of the elements in the outer list (each of which is a row of our board) and print them."


#4

Yes, I see now that the pretty print comes in the next lesson. I don't get error with your code above in lesson 5.


#5

That makes me feel slightly better. Now I wish it would just accept it so that I can move on to the next lesson.


#6

For the sake of trying, what happens if you change the parameter to x, say?

for row in x:

#7

tried that already and got the same error message. i also tried using y instead of x


#8

It isn't immediately obvious, but your board consists of zeros, not O's.


#9

That worked! Thank you very much. I wonder why that issue wasn't picked up in an earlier lesson.


#10

That is a good question, but one we will never know. This track has not been maintained in years, and will be sunsetting at some point in the coming months. Glad that we got to the bottom of it.


#11

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