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


Groups > comp.lang.python > #79019

Re: while loop - multiple condition

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: while loop - multiple condition
Date 2014-10-12 19:35 +0000
Organization A noiseless patient Spider
Message-ID <m1el67$qr1$4@dont-email.me> (permalink)
References <mailman.14792.1413133694.18130.python-list@python.org>

Show all headers | View raw


On Sun, 12 Oct 2014 17:08:00 +0000, Shiva wrote:

> while ans.lower() != 'yes' or ans.lower()[0] != 'y':

while ans.lower() is not equal to "yes"
   or ans.lower()[0] is not equal to "y"

the loop will continue to run

Note that if ans.lower() == 'y', then the first clause ( ans.lower() != 
'yes' ) is true, so the loop will continue to run, ignoring the result of 
the second clause ( ans.lower()[0] != 'y' ), This will also be the case 
if you reverse the order of the clauses.

It seems that you need a better understanding of combinatorial logic, 
perhaps http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/
index.html#booleantheorems will help.

-- 
Denis McMahon, denismfmcmahon@gmail.com

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


Thread

while loop - multiple condition Shiva <shivaji_tn@yahoo.com> - 2014-10-12 17:08 +0000
  Re: while loop - multiple condition Roy Smith <roy@panix.com> - 2014-10-12 13:28 -0400
  Re: while loop - multiple condition Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-12 19:35 +0000

csiph-web