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


Groups > comp.lang.python > #79044 > unrolled thread

Re: while loop - multiple condition

Started byChris Angelico <rosuav@gmail.com>
First post2014-10-13 22:59 +1100
Last post2014-10-14 00:48 +1100
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#79044 — Re: while loop - multiple condition

FromChris Angelico <rosuav@gmail.com>
Date2014-10-13 22:59 +1100
SubjectRe: while loop - multiple condition
Message-ID<mailman.14819.1413201543.18130.python-list@python.org>
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

[toc] | [next] | [standalone]


#79045

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-10-13 15:09 +0300
Message-ID<87d29wmas0.fsf@elektro.pacujo.net>
In reply to#79044
Chris Angelico <rosuav@gmail.com>:

> Or, even simpler: Use an active condition.
>
> while input('Do you like python?') not in ('yes', 'y'): pass

Instead of the traditional "pull" technology, you could take advantage
of the state-of-the-art "push" approach:

   print("You must love python -- everybody does!")


Marko

[toc] | [prev] | [next] | [standalone]


#79048

FromChris Angelico <rosuav@gmail.com>
Date2014-10-14 00:48 +1100
Message-ID<mailman.14822.1413208114.18130.python-list@python.org>
In reply to#79045
On Mon, Oct 13, 2014 at 11:09 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Chris Angelico <rosuav@gmail.com>:
>
>> Or, even simpler: Use an active condition.
>>
>> while input('Do you like python?') not in ('yes', 'y'): pass
>
> Instead of the traditional "pull" technology, you could take advantage
> of the state-of-the-art "push" approach:
>
>    print("You must love python -- everybody does!")

Nay, there is love in excess. I thank heaven there are many pythons in
England; but if thou lovest them all, I withdraw my thanks!
-- Colonel Fairfax

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web