Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79044

Re: while loop - multiple condition

References <loom.20141012T190458-947@post.gmane.org> <m1g2lt$8jj$1@ger.gmane.org>
Date 2014-10-13 22:59 +1100
Subject Re: while loop - multiple condition
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.14819.1413201543.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Oct 13, 2014 at 7:31 PM, Gelonida N <gelonida@gmail.com> wrote:
> Taking into account the Steven's suggestion about using the 'in' expression
> it could be:
>
>
> while True:
>     ans = input('Do you like python?')
>     if ans.lower() in ('yes', 'y'):
>         break

Or, even simpler: Use an active condition.

while input('Do you like python?') not in ('yes', 'y'): pass

ChrisA

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: while loop - multiple condition Chris Angelico <rosuav@gmail.com> - 2014-10-13 22:59 +1100
  Re: while loop - multiple condition Marko Rauhamaa <marko@pacujo.net> - 2014-10-13 15:09 +0300
    Re: while loop - multiple condition Chris Angelico <rosuav@gmail.com> - 2014-10-14 00:48 +1100

csiph-web