12 Bad Aim - Invalid Syntex


Hello,in my code i'm trying to check, if the guessed location has 'X' or not.
when i run this code, i get "syntax error" in my elif construction.
Whats wrong with it?
Thank you.

if (guess_row==ship_row) and (guess_col==ship_col):
print "Congratulations! You sank my battleship!"
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!"
elif board[guess_row][guess_col] == "X":
print "You guessed that one already"


Make sure that your formatting is correct in your post. This is very much significant in Python so you can't leave it out if you want anybody else to look at your code.


Please, take a look at my formatting. Maybe i'm really missing something


Line 38 and 39 should be before line 34. This is because you can't have an elif after an else.