12/19 Bad Aim


#1

For the following codes, why does this work:

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sunk my battleship!"
else:
if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
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 "Turn, %s" % (turn + 1)
print_board(board)

And not this:

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)


#2

HI why not i just ran it and it work


what error do you get?