Program stops


#1
for turn in range(10):
    guess_row = int(raw_input("Guess Row:"))
    guess_col = int(raw_input("Guess Col:"))

if guess_row == ship_row and guess_col == ship_col:
    print "Congratz you have won !"
    break
else:
    if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
        print "Oops thats outta ocean"
    elif board[guess_row][guess_col] == "X":
        print "You guessed that one already"
    else:
        print "Try again"
board[guess_row][guess_col] = "X"
print_board(board)

Okay everything works alright but, if I go out of my board range i.e.(10,1) my program stops and prints IndexError: list assignment index out of range instead of looping back.


#2

Try indenting board[guess_row][guess_col] = "X" so that it is included in the if/elif/else statement. You need to make sure the guess is in the board before you assign anything.