Bad Aim . Explanation Please?


#1

I am wondering why to indent board[guess_row][guess_col] = "X" and print_board(board) to print?
It should work without indenting too?. On the 11th lesson i had not indented it but why here?.

if guess_row == guess_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" # Why this two lines to be indented?.
         print_board(board)

Any help is greatly appreciated.
Thanks.


#2

I suppose that the X marks a missed shot and not a successful one. This code is the first step for a more complex situation where we can enter several guesses until the ship is sunk. In this situation, printing the missed shots makes sense. So the two lines that you mention must be indented in order to be executed after the "print "You missed my battleship!"" and not in other cases.


#3

Thank you very much for your help!!