Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: while loop - multiple condition Date: Sun, 12 Oct 2014 22:16:56 +0300 Organization: A noiseless patient Spider Lines: 26 Message-ID: <878uklcd3r.fsf@elektro.pacujo.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="20673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/SK2UjEiBYmE3Y5MINlQO" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:C6CzYRLxMYtgGHc8E/7U0SCbL2A= sha1:gIiaQWQskBlcxS4FqYGJSHbnOrY= Xref: csiph.com comp.lang.python:79017 Chris Angelico : > On Mon, Oct 13, 2014 at 4:59 AM, Shiva > wrote: >> Bit confusing to use in While loop - Should have used the 'and' condition >> instead of OR- then it works fine. >> for OR both condition need to be false to produce a false output and break >> the loop. > > Correct, what you're looking for here is indeed an 'and' (also called > a conjunction, as opposed to the disjunction of 'or'). Both operators > are important; and you need to understand what they do so you know > when to use each. 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': ans = input('Do you like python?') Marko