I wonder if you can help me; I am struggling to complete exercise 12 of Battleship. I cannot get the code to print the out of range
statement, "Oops, that's not ..." using the code supplied in the
exercise. When I implement alternative code that uses* try/except*
try: if guess_row == ship_row and guess_col == ship_col: print("Congratulations! You sank my battleship!") else: board[guess_row][guess_col] = "X" print_board(board) print("You missed my battleship!") except IndexError: print("Oops, that's not even in the ocean!")
the program works as expected, but the Site interface shows and Error
message, 'Make sure you print, "Oops, that's not even in the ocean!" if
the user guesses a row or column that is off the board."'
How do I resolve this problem?
P.S. I have since found out where the problem lay; it was an inadvertent substitution of character - an exclamation mark for a period. The 'Oops, ..." statement should end with a period. How such a small thing can create a lot of bother!