[Tutor] Break Help

Corey Richardson corey at octayn.net
Wed May 30 03:08:12 CEST 2012


On Tue, 29 May 2012 17:50:37 -0700 (PDT)
PhantomsCore <thomasjo2 at wsdstudent.net> <thomasjo2 at wsdstudent.net>
wrote:

> 
>     if gameIsDone:
>         if playAgain():
>             missedLetters = ''
>             correctLetters = ''
>             gameIsDone = False
>             secretWord = getRandomWord(words)
>         else:
>               break
> 
> That is my coding. When I try to run it I get "Break outside loop"
> 

Because (surprise!) you are using break outside of a loop. Break is
only valid to break out of a for or while loop, and no where else. What
do you want to do with that program? Quit if playAgain() returns false?
Just leave out the else entirely, and if gameIsDone is False, it will
continue outside of that block.


More information about the Tutor mailing list