Bad aim


#1

Write your code below!

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sank my battleship!"
else :
if guess_row or guess_col < 0 or guess_col or\
guess_row > 4:
"Oops, that's not even in the ocean."
else:
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
print_board(board)

Oops, try again.
Your code looks a bit off. Check the Hint if you need help! Your
code threw the following error: unindent does not match any outer
indentation level (python, line 35)

i am really stuck here


#2

The error you're getting mentions indentation, but we can not see your indentation because your post is not formatted as code. See this post on how to format code in a post.


#3


#4

Ok, so look at the error. It's telling you the indentation of your else statement on line 35 is not correct. Look at your previous if & else statement and how their indentations line up. Try adjusting the indentation of the else statement on line 35, don't forget to also adjust the indentation of lines that are part of that else statement.


#5

i just checked it all and i can not find the mistake i am realy stuck


#6

This code works for me. The if and else statements inside the first else statement are both indented one tab. In yours, the bottom else statement on line 35 looks to be indented more than one tab. Try lining the else on line 35 with the if on line 32 and see how your code works(don't copy and paste mine, that's cheating :stuck_out_tongue:)

# Write your code below!
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:
        print "You missed my battleship!"
        board[guess_row][guess_col] = "X"
        print_board(board)

#7

now i get another error


#8

Look at this screenshot. I added red lines next to the code. See how the indentation is uniform? Try to make your indentation look like mine.


#9

it works thank you for your time


#10

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