Confused by this syntax error, can someone please point out my error more explicitly?


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/1/4?curriculum_id=4f89dab3d788890003000096#


File "python", line 38
elif board[guess_col][guess_row] = "X":
^
SyntaxError: invalid syntax


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


#2

Assignment is not an expression, so it can't be used as a condition.

Also, coordinate 6 is outside the ocean by more than 1 step, what is the last valid coordinate?


#3

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