Bad aim


#1




Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: list index out of range

What i am doing wrong?

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


#4

The above lines are in the wrong position. Recommend go back to the beginning and work through the instructions one by one to correct the ordering of your lines.

Consider using elif in sequence, and else only in the last case.

if ___:

elif ___:

elif ___:

else:

#6

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