Battleship 6/13 error


What is wrong with my code? Ive tried several things none work. This is the same code I used for the prior section and it passed the lesson fine. Can someone help, please?


def create_board(lst):
 for x in range(0,5):

### New Function ###

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


Which part is this exactly and what is the error you’re getting?


I don’t know where the mistake is. Everything looks fine. I pried calling: Print Print_board(board) and it doesn’t work either.

the error I get is :slight_smile:

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


did you try to put the board list as argument to your create_board() function?


Are you using a lower-case “o”? It’s requesting upper-case, maybe that’s the problem?

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

for some reason this way worked for me.`


Hi Guillermo,

You had two problems:

  1. You didn’t call create_board and then print_board using board as an argument for both the calls.
  2. You had to use upper-case "O" rather than "o".


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


This function & call outputs the clean 5x5 grid without punctuation, which is what we want.

This Q has a few bugs, I initially passed the page without calling the function (by writing print board) then re-read the instructions. Of course by not calling the function the output was the same list format with square parentheses, commas and quotations. I tried a few different ways, many of which were passed, before realising that I needed to call the function rather than print the initial list.

So I’d say that this section requires a few more checks before passing. Your output looks a bit off, did you call your function?