while loop - multiple condition
Denis McMahon
denismfmcmahon at gmail.com
Sun Oct 12 15:35:35 EDT 2014
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 at gmail.com
More information about the Python-list
mailing list