Danger, Will Robinson!


#1

Hi, I am stuck on the exercise “Danger, Will Robinson!!”, can some one help me please? I don’t understand the “Make sure to enter a col and row that is on the board!”

Instructions:
Add an else under the if we wrote in the previous step.

Print out “You missed my battleship!”

Set the list element at guess_row, guess_col to “X”.

As the last line in your else statement, call print_board(board) again so you can see the “X”.Make sure to enter a col and row that is on the board!

Error:
Make sure to enter a col and row that is on the board!

My code:


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



#2

Hi @jfas02,

This does not set the guessed location to "X" within the variable, board

    guess_row = "X"
    guess_col = "X"

You need, instead, to use guess_row and guess_col as indexes to access board, as follows …

    board[guess_row][guess_col] = "X"

#3

Thank you for the help.


#4