Unindent issue, am I nesting my if/else statements properly?


#1

turn = 0
if turn < 3:
	print_board(board)
	print("Turn", turn + 1)
	print(ship_row)
	print(ship_col)
        if guess_row == ship_row & guess_col == ship_col:
    	        print("Congratulations! You sank my battleship!")
    	        break
        else:
    	        if board[guess_row][guess_col] == "X":
	    	        print("You guessed that one already.")	    
    	        else:
    	         	for i in range(5):
    			        if guess_col or guess_row != i:
	        		           print("Oops, that's not even in the ocean.")	
    		        print("You missed my battleship!")
	    	        board[guess_row][guess_col] = "X"
else:
    print "Game Over"

Getting an error at this line:
if guess_row == ship_row & guess_col == ship_col:

This happened out of nowhere when I added the break line like I was supposed to, and now I can't get this program to run.

Why do these error pop up in python? No matter how many times I delete the space and retab it's not working.


#2

having issues with "["code][/code"]" as well, but I think you get the gist.


#3

Hi donraj00,

Which exercise are you talking about? breaks are only used inside a loop. You don't have a loop in your code, and that's why you are getting the error on line 9.


#4

Thanks for the help, I had to rewrite my whole code but it's working now.