[Tutor] How do I create a "loop until" looping structure?

Greg Schroeder gmschroeder at gmail.com
Wed May 21 15:09:23 CEST 2014


https://wiki.python.org/moin/WhileLoop

Greg

On Wed, 2014-05-21 at 18:32 +0800, 1 2 wrote:
> Hi there,
>   As shown in the codes below, I want to end the loop until the s is
> no greater than -5 but I found there is no "do... loop until..." like
> C so what should I do? I will write it in C's style
> 
> s,n = 0,1
> do:
>     import math
>     s=s+(math.log((n+1)/(n+2))/math.log(2))
> loop until s < -5
> print(s)
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list