[Tutor] repeat
Scott SA
pydev at rscorp.ab.ca
Sat Nov 17 09:01:09 CET 2007
On 11/17/07, Michael (python at mrfab.info) wrote:
>This has probably been asked before but can I get some clarification on
>why Python does not have a repeat...until statement, and does that mean
>repeat...until is bad practice? I was trying to get Python on the
>standard langauge list for my state secondary school system but they say
>a langauge must have a test last structure in it to be considered.
While you may feel your assertion to be true, it will persist until discovered false...
<http://docs.python.org/ref/while.html>
... to date has satisfied my needs for the task. 8^)
Like many things in Python there are alternates, even to this (I expect to be learning more of them myself for a good long time 8^)
More examples and detail can be found at:
<http://www.diveintopython.org/>
<http://www.pasteur.fr/formation/infobio/python/ch10s03.html>
<http://www.freenetpages.co.uk/hp/alan.gauld/tutloops.htm>
Simply put:
while [test]:
do something
or
while True:
do something
if [test]:
break
x = 0
while x < 100:
x += 1
print x
100
Still, the links can elaborate more than I can.
HTH
Scott
More information about the Tutor
mailing list