12.bad aim help need


#1



here the logic can be understandable but unable to produce it

am in stuck in else / if loop part


File "python", line 34
print "Oops,that's not even in the ocean"
^
IndentationError: expected an indented block

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: expected an indented block (python, line 34)


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:
        board[guess_row][guess_col] = 'X'
        print "You missed my battleship"
        print print_board(board)


#2

the error message describes it very clear - your indention is wrong.
it should look like:


#3

"""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:
    board[guess_row][guess_col] = 'X'
    print "You missed my battleship"
    print print_board(board)"""

in output it shows like this
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Guess Row: 5
Guess Col: 2
0
2
Oops,that's not even in the ocean
None

Oops, try again. Make sure you print "Oops, that's not even in the ocean." if the user guesses a row or column that is off the board.


#4

there should be a .(period) at the end and a space after the comma in the line. It should be like

if guess_row not in range(5) or guess_col not in range(5):
print "Oops ,that's not even in the ocean."

rest same


#5

thanks for the help
I have surpassed the state after a couple of hours


#6

You can't have two else, rather modify one as elif ( which can be repetitive)


#7

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