Board apparently not printing right


#1

Hi, I am on the Custom Print exercise of Battleship, and the code editor says my code isn't printing what it's supposed to. It looks like it is to me, 5 rows of 5 "O"s, in order.

Here is my code:

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

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


#2

Are you sure. you must be fooling around. Try this:
for x in range(0, 5):
board.append(["O"] * 5)

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

print_board(board)


#3

I have that code exactly. Here is what it says when I hit submit:

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


#4

Figured it out. At that point in the exercise I wasn't supposed to be using print " ".join(row). I was just supposed to have print row.


#5

Sometimes if you don't follow exactly what has been given in the
instructions, the interpreter will throw errors. So it is better to follow
the instructions


#6

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