How does the Battleship - not again code work?

Hi,

I am not understanding how this piece of code works, this is to tell the user he has already entered the same answer earlier in the Battleship game of the Lists and Functions -

elif board[guess_row][guess_col] == “X”:
print( “You guessed that one already.” )

Referring to this exercise - https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/not-again

Given we mark already guessed spots with an X on the board, if a coordinate on the board equals X (not O), the user has guessed that coordinate before.

1 Like

This may be confusing because as of this exercise, you can only make one guess per game. In a later exercise within the Battleship! course, you will create a loop that will allow up to four rounds. After the loop has been created, there will be an "X" in board wherever you have made an incorrect guess.