Newbie question related to Boolean in Python

Tim Roberts timr at probo.com
Fri Sep 6 00:02:04 EDT 2013


skwyang93 at gmail.com wrote:
>
># 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.
>
> 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.

I'm not quite sure what you're expecting.  There is nothing in any of the
cases that will exit the loop.  The loop is infinite.  I assume (with no
evidence) that the "dead" function calls sys.exit, which kills the program.
In that case, this makes a little bit of sense.  The first time you type
"taunt bear", bear_moved is set True and the loop runs again.  If you type
"taunt bear" a second time, then the bear is pissed off and you call
dead().
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list