12 Bad Aim - Invalid Syntex


#1

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!"
else:
if guess_row not in range(5) or guess_col not in range(5):
print "Oops, that's not even in the ocean."
else:
print "You missed my battleship!"
board[guess_row][guess_col]="X"
print_board(board)
elif board[guess_row][guess_col] == "X":
print "You guessed that one already"


#2

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.


#3


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


#4

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