Danger, Will Robinson!


I think there might be an error in : board[guess_row][guess_col] = 'X'
If this in incorrect it will affect the other exercises below.

Hope to get correction

if guess_row == ship_row and guess_col == ship_col:
    print "Congratulations! You sank my battleship!"
    print "You missed my battleship!"
board[guess_row][guess_col] = 'X'


Hi, @ryan_beijing ,

This needs to be indented correctly, so that the 'X' is placed on the board only when the user misses the battleship ...

board[guess_row][guess_col] = 'X'

As you have it now, it is not part of the else block.

Regarding this statement, also indent it if you would like to display the board only when the user misses the battleship ...


That, in fact, is the only event upon which the configuration of the board changes. You need to decide what would be the best occasion for displaying the board.


so I should indent the last two statements to make it on the same vertical line with the third to the last print statement?


If you indent those two statements in the manner that you have described, they will be part of the else block. That is what you should do if you agree that those two statements should be executed only when the player misses the battleship.

Consider whether the above makes sense, try it out, and let us know whether you are satisfied with the result.


So if the X is displayed when a wrong guess is made and the X will be marked on the coordinate of the guess?


Yes. Try it out to confirm that. When checking the board to make sure it is correct, remember that the rows and columns are numbered from 0 to 4.


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