Replace for Goto

Gerrit Holl gerrit at nl.linux.org
Sun Jun 1 23:14:10 CEST 2003


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

yours,
Gerrit.

-- 
100. ... interest for the money, as much as he has received, he shall
give a note therefor, and on the day, when they settle, pay to the
merchant. 
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list