Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53741
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'operator': 0.03; 'elif': 0.05; 'true,': 0.05; 'subject:Python': 0.06; 'suppose': 0.07; 'advance': 0.07; 'answering': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:related': 0.09; 'subject:question': 0.10; 'question.': 0.14; '"not"': 0.16; '16.': 0.16; '17.': 0.16; 'door.': 0.16; 'indent': 0.16; 'initially,': 0.16; 'loop.': 0.16; 'means.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'input': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'moved': 0.30; 'lines': 0.31; 'front': 0.32; 'run': 0.32; '"the': 0.34; 'there': 0.35; 'false': 0.36; 'next': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'conditions.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'numbers': 0.61; 'first': 0.61; "you've": 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'face': 0.64; 'here': 0.66; '11.': 0.74 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Newbie question related to Boolean in Python |
| Date | Thu, 5 Sep 2013 20:47:35 +0000 (UTC) |
| References | <f2259124-4af1-4608-9969-8e42a140633e@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 174.32.174.36 |
| User-Agent | XPN/1.2.6 (Street Spirit ; Linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.106.1378414084.5461.python-list@python.org> (permalink) |
| Lines | 46 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1378414084 news.xs4all.nl 15897 [2001:888:2000:d::a6]:56100 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53741 |
Show key headers only | View raw
On 5/9/2013 16:08, skwyang93@gmail.com wrote:
> 1. bear_moved = False
> 2.
> 3. while True:
> 4. next = raw_input("> ")
> 5.
> 6. if next == "take honey":
> 7. dead("The bear looks at you then slaps your face off.")
> 8. elif next == "taunt bear" and not bear_moved:
> 9. print "The bear has moved from the door. You can go through."
> 10.
> 11. bear_moved = True
> 12. elif next == "taunt bear" and bear_moved:
> 13. dead("The bear gets pissed off and chews your leg off.")
> 14. elif next == "open door" and bear_moved:
> 15. gold_room()
> 16. else:
> 17. print "I got no idea what that means.
>
Please indent by 4, not 2 characters. It's very hard to see what's
lined up with what. And that's compounded by having the line numbers
there so that the first 9 lines are shifted left.
> # This is just to show my understanding of Boolean. In line 8-9, if my input is "taunt bear", the result is true and true, which will continue the loop.
Those lines have compound if conditions. Line 8 will be true/true
only the first time you type "taunt bear". Notice the operator "not" in
front of bear_moved.
>
> # So what confused me is line 12-13. if my input is taunt bear, is it suppose to be taunt bear == "taunt bear" and bear_moved which is true and true? which means the loop will continue instead of cancelling it.
Line 12 will be true/true only if you've already run line 11. Since
bear_moved = False initially, the only way you get true /true here is by
answering "taunt bear" twice.
>
> Thanks in advance for spending your time to answer my question.
> Source: Learnpythonthehardway
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Newbie question related to Boolean in Python skwyang93@gmail.com - 2013-09-05 13:08 -0700
Re: Newbie question related to Boolean in Python Neil Cerutti <neilc@norwich.edu> - 2013-09-05 20:38 +0000
Re: Newbie question related to Boolean in Python Thomas Yang <skwyang93@gmail.com> - 2013-09-05 16:36 -0700
Re: Newbie question related to Boolean in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-06 02:28 +0000
Re: Newbie question related to Boolean in Python Dave Angel <davea@davea.name> - 2013-09-05 20:47 +0000
Re: Newbie question related to Boolean in Python Tim Roberts <timr@probo.com> - 2013-09-05 21:02 -0700
csiph-web