Printing Pretty Question


#1

The following code did "work" (meaning code academy said it was ok), but it didn't print what it was supposed to, and I'm wondering if anyone can tell me why not.

board = []
for i in range(5): 
    board.append(['O']*5) 
for x in board: 
    print x
def print_board(board):
    for row in board: 
        print " ".join(row)

['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']
None

instead of just OOOOO's.

`


#2

because this is the code that runs:

for x in board: 
    print x

and each row is just an array. If you want to print pretty, use the print_board function, but function only work if you call them:

print_board(board)

#3

The above should work. But it you want to print the OOOOO's you can use code like the below:

for i in range(0, len(board)):
print " ".join(board[i]) ;