Not Again!


#1



I have an invalid syntax message on my elif statement I looked at other forums but none of the solutions they used helped, what did I do wrong??


    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."
    elif board[guess_row][guess_col] == 'X'
    print "You guessed that one already"
    else:
        print "You missed my battleship!"
        board[guess_row][guess_col] = 'X'
        print board


#2

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sank my battleship!"
elif guess_row < 5 and guess_col < 5 :
print "You missed my battleship!"
board[int(guess_row)][int(guess_col)] = "X"
print_board(board)
elif guess_row and guess_col == X:
print "You guessed that one already."
else:
print "Oops, that's not even in the ocean."

This is the code.

You have kinda mixed it up because the "else:" in the 3rd row of that code is blocking it. In addition to that it is just one if statement and not two.


#3

missing colon at the end of your elif condition, and not properly indented on the next line.


#4

I tried the indention and the colon it still says I am wrong


#5

I put the colon in the wrong spot . . . Thanks for your help!!


#6

Yep, then it won't work :stuck_out_tongue: Good job you figured it out :slight_smile:


#7

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