Replace for Goto

Dan Bishop danb_83 at yahoo.com
Mon Jun 2 04:50:03 CEST 2003


Gerrit Holl <gerrit at nl.linux.org> wrote in message news:<mailman.1054502105.3038.python-list at python.org>...
> Gerhard Häring schreef op donderdag 29 mei om 03:04:37 +0000:
> > Use a never-ending while loop, then use an "if" and a "break". Like this:
> > 
> > while 1:
> >     # do stuff
> >     answer = raw_input("Want to play again? (y/n)").upper()
> >     if answer == 'N':
> >         break
> 
> Or, even better:
> 
> while raw_input("Want to play again? (y/n)").upper()[0] != 'N':
>     # do stuff

But you've changed the meaning.  Your way asks the player if they want
to play again before they've played the first time.




More information about the Python-list mailing list