Not again


i keep getting the inavild syntax error on the elif statement ive tired unindenting and also indenting it more yet still get it

print "You missed my battleship!"
board[guess_row][guess_col] = "X"
if guess_row not in range(5) or guess_col not in range(5):
print "Oops, that's not even in the ocean."
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
"You guessed that one already."


Did you write the elif condition correctly?
I think it should be
elif board[guess_row][guess_col] = "X" :
and then the print statement


It should be
elif board[guess_row][guess_col] == "X"

Always use "==" when checking for equality


Couple things:

  1. Make sure board[guess_row][guess_col] == "X"
  2. Make sure your elif statement appears between your if and else statements


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