12. Bad Aim Help!


#1




Hi. So everything seemed fine until at line 37 an error message keeps popping off telling me "expected an indented block" in my 'else' statement. I'm fairly new to python so I keep having these minor indentation problems from time to time. Any help would be appreciated. Thanks.


if guess_row == ship_row and guess_col == ship_col:
    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."
    else:


#2

Hello, I believe you forgot to include one extra line of code which prints: "You missed my battleship!"

So, it should look like the following:

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!"

This is why it is communicating an error on line 37; The program expects another line of code.


#3

oh haha. my bad. Thank you for your help!


#4

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