Battleship!


#1


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

i am getting this error #Oops, try again. It looks like you function didn't print out the correct response!.

Am expected to Printing Pretty by getting rid of commas and question marks around 'O'


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


#2

Your help will be appreciated much..Thank you in advance


#3

your board:

OOOOO
OOOOO
OOOOO
OOOOO
OOOOO

the desired board:

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

you need a space between your columns.


#4

oh yeah, Thank for that, but am not yet sure with how i can include the spaces between the columns ...more assistance please


#5

the character between the quotation marks is what .join() use to concat the string


#6

Hello,

I got the board I wanted with this:

for i in range (5):
print(('O' + ' ')*5)

Do I have to go the long way?

Lemonade


#7

you have a bit of a way to go. The reason we use a list is so we can mark a users guess wrong with X. Without the list, you can't achieve this.

The list also allows us (given the user gets multiply tries to guess the ship) to check if the user hasn't already guessed the coordinates he entered and so on.


#8

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