13. Not Again! I passed but my code is not marking "X" for incorrect guesses


There's something wrong here, since an "X" does not appear for my incorrect guesses, ever since I added the elif. What happens instead is it just says "You missed my battleship!" without leaving an "X". How do I fix this?

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


The 2nd line of you else statement is making a comparison. We use == when we want to compare if two things are equal. If you want to set the value of a variable or in this case an item in an array we use a single =


Your problem roots from here. Using this function:


is the same as an equal to sign in math. It is suppose to be this sign:


which assigns a value. That should fix your problem. :slight_smile:

-- @chipjumper36731


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