Why won't break work?


#1

The task is to add a break under the win condition, here is what I did:

if guess_row == ship_row and guess_col == ship_col:
    print "Congratulations! You sunk my battleship!" 
    break

but it says:

SyntaxError: 'break' outside loop

I tried to move 4 spaces back and 4 spaces forward but nothing worked. What do I do?


#2

Have you reached the lesson where the for loop is added? Then it would make sense to use break so the loop (and the game) comes to an end.


#3

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