Help! custom print error


#1



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

result
[['O'], ['O'], ['O'], ['O'], ['O']]
[['O'], ['O'], ['O'], ['O'], ['O']]
[['O'], ['O'], ['O'], ['O'], ['O']]
[['O'], ['O'], ['O'], ['O'], ['O']]
[['O'], ['O'], ['O'], ['O'], ['O']]

it said it was not the correct response


#2

You need to print each row, not the the board.


#3

You are suppose to make it a string and join each row with the .join() method. Right now your for loop is just spewing back what you gave it unformatted becuase you put a simply print board statement.


#4

was the .join() method touched on earlier in the tutorial? or are there text books or other resources that you are using to find these methods? thank you


#5

It was introduced in the Codecademy lessons although I can't remember which one. :confused:


#6

Right thanks, i've been doing this in chunks and leaving it too long in between lessons. i should probably start from the beginning again to refresh. Thanks Chip!


#7

You're welcome, and that may be a good idea. Just a heads up, the courses for Python and some other things are going to be updated in the near future, and progress will be affected, so you might want to finish quickly. Here's more on that:

Important Changes to Codecademy Courses


#8

Thanks for the forewarning. I better get crackin, only at 50%!


#9

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

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

print_board(board)

This worked for me. If it still needed.


#10

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