Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43832
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Novice Issue |
| Date | Thu, 18 Apr 2013 14:21:36 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 22 |
| Message-ID | <kkovhf$ftp$1@reader1.panix.com> (permalink) |
| References | <0fa050c1-3a00-4c17-9fa6-b79a22485c7a@googlegroups.com> |
| NNTP-Posting-Host | panix2.panix.com |
| X-Trace | reader1.panix.com 1366294896 16313 166.84.1.2 (18 Apr 2013 14:21:36 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Thu, 18 Apr 2013 14:21:36 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | csiph.com comp.lang.python:43832 |
Show key headers only | View raw
In <0fa050c1-3a00-4c17-9fa6-b79a22485c7a@googlegroups.com> Bradley Wright <bradley.wright.biz@gmail.com> writes:
> while raw_input != "quit" or "q":
Others have pointed out flaws in this statement. However, even if you
had written the loop the 'correct' way:
user_input = raw_input()
while user_input != "quit" or user_input != "q":
There is still a logic bug. This loop will execute forever, because no
matter what the user enters, it will be unequal to "q" or unequal to "quit".
Use 'and' instead of 'or'.
Of course in this specific situation, as others have suggested, 'in' is
better still.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Novice Issue Bradley Wright <bradley.wright.biz@gmail.com> - 2013-04-17 21:06 -0700
Re: Novice Issue Chris Angelico <rosuav@gmail.com> - 2013-04-18 14:14 +1000
Re: Novice Issue Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-04-18 08:58 +0000
Re: Novice Issue Chris Angelico <rosuav@gmail.com> - 2013-04-18 19:06 +1000
Re: Novice Issue Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-18 11:10 +0100
Re: Novice Issue Bradley Wright <bradley.wright.biz@gmail.com> - 2013-04-18 05:18 -0700
Re: Novice Issue Dave Angel <davea@davea.name> - 2013-04-18 08:29 -0400
Re: Novice Issue Bradley Wright <bradley.wright.biz@gmail.com> - 2013-04-18 05:34 -0700
Re: Novice Issue John Gordon <gordon@panix.com> - 2013-04-18 14:21 +0000
csiph-web