Test run debugging!


#1
if guess_row ==ship_row or guess_col==ship_col:
    print "Congratulations! You sank my battleship!"
else:
    print "You missed my battleship!"
    board[int(guess_row)][int(guess_col)]="X"
    
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[int(guess_row)][int(guess_col)]=="X":
    print "You guessed that one already."
else:   
    print "You missed my battleship!"
    board[int(guess_row)][int(guess_col)]="X"
    print_board(board)

if i go out of the range i get an error message like that:
Guess Row: 6
Guess Col: 6
3
3
You missed my battleship!
Traceback (most recent call last):
File "python", line 33, in
IndexError: list index out of range


#2

It seems like it's crashing because you have 2 if statements, with the first one not checking for the proper range. When you enter 6 and 6 it will crash on the else part in the first if statement, because board[6][6] does not exist.

What you have to do is remove the else part in your first if statement, since it does the same thing already later on in your code.