11. Danger, Will Robinson!


#1

Hi everyone!

My problem is, that i dont know what they mean with the "As the last line in your else statement, call print_board(board) again so you can see the "X"."

Can someone help?

if guess_row == ship_row:
    print "Congratulations! You sank my battleship!"
else:
    print "You missed my battleship!"
if guess_col == ship_col:
    print "Congratulations! You sank my battleship!"
else:
    print print_board(board)


#2

you need to set the guessed coordinate to X:

board[x][y] = "X"

now, i will leave you to think what x and y should be.


#3

Hope this helps you!

As you can remember you are starting with blank board (5X5 "O"). So, after the guess from player you have to put X on the spot where the guess is.
After you put X on board (Set the list element at guess_row, guess_col to "X"), you should print new board with X on it (As the last line in your else statement, call print_board(board) again so you can see the "X".).
It should be like this:
...
else:
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
print_board(board)


#4

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