Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string': 0.09; 'subject:while': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'ans': 0.16; 'character.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'lowercase': 0.16; 'received:10.216': 0.16; 'throw': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'equivalent': 0.26; 'header:In- Reply-To:1': 0.27; 'crash': 0.31; 'except': 0.35; 'charset:us- ascii': 0.36; 'effort': 0.37; 'received:10': 0.37; 'rather': 0.38; 'improved': 0.60; 'entire': 0.61; 'first': 0.61; 'situation': 0.65; 'characters,': 0.84 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1413146393614:3435492471 X-MC-Ingress-Time: 1413146392554 Date: Sun, 12 Oct 2014 15:42:35 -0500 From: Tim Chase To: Marko Rauhamaa Subject: Re: while loop - multiple condition In-Reply-To: <878uklcd3r.fsf@elektro.pacujo.net> References: <878uklcd3r.fsf@elektro.pacujo.net> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AuthUser: tim@thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413146405 news.xs4all.nl 2839 [2001:888:2000:d::a6]:33207 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79024 On 2014-10-12 22:16, Marko Rauhamaa wrote: > is equivalent with > > while ans.lower()[0] != 'y': > ans = input('Do you like python?') And still better improved with while ans[:1].lower() != 'y': ans = input('Do you like python?') in the event that len(ans)==0 (a situation which will crash the various current examples). It also only expends the effort to lowercase 0-or-1 characters, rather than lowercasing an entire string just to throw away everything except the first character. -tkc