Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79018
| References | (2 earlier) <loom.20141012T191849-946@post.gmane.org> <CAPTjJmouQsm_9ccqdtmJ3kmd4SqmmOqk3OVdS4mngeHaVT2S6w@mail.gmail.com> <loom.20141012T195709-937@post.gmane.org> <mailman.14798.1413137019.18130.python-list@python.org> <878uklcd3r.fsf@elektro.pacujo.net> |
|---|---|
| Date | 2014-10-13 06:22 +1100 |
| Subject | Re: while loop - multiple condition |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14801.1413141753.18130.python-list@python.org> (permalink) |
On Mon, Oct 13, 2014 at 6:16 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> The corrected version
>
> while ans.lower() != 'yes' and ans.lower()[0] != 'y':
> ans = input('Do you like python?')
>
> is equivalent with
>
> while ans.lower()[0] != 'y':
It's true that the first part is redundant, but trimming that out
wouldn't have taught the OP about boolean logic :)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: while loop - multiple condition Chris Angelico <rosuav@gmail.com> - 2014-10-13 05:03 +1100
Re: while loop - multiple condition Marko Rauhamaa <marko@pacujo.net> - 2014-10-12 22:16 +0300
Re: while loop - multiple condition Chris Angelico <rosuav@gmail.com> - 2014-10-13 06:22 +1100
Re: while loop - multiple condition Tim Chase <python.list@tim.thechases.com> - 2014-10-12 15:42 -0500
Re: while loop - multiple condition Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-13 09:56 +1100
Re: while loop - multiple condition Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-13 09:12 -0700
Re: while loop - multiple condition Rustom Mody <rustompmody@gmail.com> - 2014-10-13 09:26 -0700
Re: while loop - multiple condition Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-13 09:43 -0700
Re: while loop - multiple condition Rustom Mody <rustompmody@gmail.com> - 2014-10-13 10:12 -0700
Re: while loop - multiple condition Michael Torrie <torriem@gmail.com> - 2014-10-13 16:08 -0600
Re: while loop - multiple condition wxjmfauth@gmail.com - 2014-10-13 23:34 -0700
Re: while loop - multiple condition giacomo boffi <pecore@pascolo.net> - 2014-10-15 01:04 +0200
Re: while loop - multiple condition Chris Angelico <rosuav@gmail.com> - 2014-10-15 10:16 +1100
csiph-web