Battleship Project has Confusing Instructions for Element X in Part 11

https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/danger-will-robinson

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!

I don’t know what it means by ‘set the list element at guess_row, guess_col to X’. I don’t think it wants me to modify what goes on the board, so I try pointing to an element X for ship_row and ship_col in the if statement, but it gives an indentation error. I indented the print statements for else, btw.

# Write your code below!
if guess_row == ship_row[X] and guess_col == ship_col[X]:
	print "Congratulations!  You sank my battleship!"
else: 
  print "You missed my battleship!"
	print print_board(board)

Indentation is not for our convenience but for the interpreter to know our code structure. Above, X is totally in the wrong context. guess_row should only equal ship_row, which is an index not a list. The two values (ship_row and ship_col) combined make up the coordinates of the ship on the board.

board[guess_row][guess_col] = 'X';

Yeah, I’m face palming now, because it was after I checked the solution, that I was able to realize why that was the answer.

1 Like