[Tutor] repeat

Michael H. Goldwasser goldwamh at slu.edu
Sat Nov 17 16:20:37 CET 2007


On Saturday November 17, 2007, Michael wrote: 

>    Hi All
>    
>    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.


That is quite an arbitrary rule for a state to use when adopting a
programming language.  In any event, if they are also uncomfortable
with the while(True)/break combination that has been suggested by
others, you can alternatively mimic the repeat/until by using a
well-named boolean variable, as follows.


repeating = True
while repeating:

    # ...


    if (exitCondition):
        repeating = False



or in a negated form (if that reads better), as


done = False
while not done:

    # ...

    if (exitCondition):
        done = True



Perhaps these kinds of examples might help ease their concerns.

With regard,
Michael




More information about the Tutor mailing list