6/19 Printing Pretty (Battleship)


#1

What is wrong with my code?
board = []
for item in range(5):
board.append(['O'] * 5)

def print_board(board):
for lst in range(0, len(board)):
print " ".join(board[lst])

print print_board(board)

It works on the previous section (5 - Custom Print). All I did here was to add
" ".join(row) as per the instructions.
The output I get is:
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
None
And considering the expected output, it seems to be the correct output. But I keep getting this error:


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

Alternative ways of writing out the code are welcome, but I would also like to understand why my code isn't accepted.


#2

try

def print_board(lists = []):
    for i in board:
        print " ".join(i)

print_board(board)

#3

I get the same output and error.


#4

funny thing is I just tested both version of the code(your code and what I suggested) and they both worked


#5

Honestly I don't get why it isn't working. This is my third pc (two windows and one mac), and I keep getting the same thing. Maybe it's my account.. perhaps a logout for some time will have it cleared, I don't know.
Anyway, thank you for your help and timely responses.