Custom Print - Battleship!


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/0/5?curriculum_id=4f89dab3d788890003000096#


When I run the code I get this error message: Oops, try again. It looks like you function didn't print out the correct response!


I expected this code to be fine, I've copied it from other users who have moved further along in the course. My output is below:

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


board = []

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

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

print_board(board)

Anybody understand what the issue is? Please advise.


#2

That is the code for the next lesson "Printing Pretty" for "Custom Print" you want to use:

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

print_board(board)

#3

Ah, that helps me out. Many thanks.


#4

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