On 2008-11-13, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-11-13, jzakiya <[EMAIL PROTECTED]> wrote: >> I'm translating a program in Python that has this IF Then chain >> >> >> IF x1 < limit: --- do a --- >> IF x2 < limit: --- do b --- >> IF x3 < limit: --- do c --- >> .----- >> ------ >> IF x10 < limt: --- do j --- >> THEN >> THEN >> ----- >> THEN >> THEN >> THEN > > The placement of the THEN statements makes absolutely no sense > in any language I've ever seen. > >> In other words, as long as 'xi' is less than 'limit' keep going >> down the chain, and when 'xi' isn't less than 'limit' jump to end of >> chain a continue. >> >> Is this the equivalence in Python? >> >> IF x1 < limit: >> --- do a --- >> elif x2 < limit: >> --- do b --- >> ---- >> ---- >> elif x10 < limit: >> --- do j --- > > No. That's not the same at all. > > > Here's one solution: > > while True: > if x1 > limit: break > do a > if x2 > limit: break > do b > if x3 > limit: break > do c > ... > if x10 > limit: break > do j > break
Oops. I botched the case where xN == limit. Each of the tests should be xN >= limit. -- Grant Edwards grante Yow! ... I see TOILET at SEATS ... visi.com -- http://mail.python.org/mailman/listinfo/python-list