Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assign': 0.07; 'subject:help': 0.08; 'function,': 0.09; 'global,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'typed': 0.09; 'subject:question': 0.10; 'def': 0.12; "'yes',": 0.16; 'email addr:comcast.net': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'slight': 0.16; 'subject:beginner': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'input': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'this:': 0.26; 'asking': 0.27; 'header:X -Complaints-To:1': 0.27; 'function': 0.29; 'statement': 0.30; "i'm": 0.30; 'asked': 0.31; 'probably': 0.32; 'subject: (': 0.35; 'problem.': 0.35; 'something': 0.35; 'but': 0.35; 'false': 0.36; 'var': 0.36; 'charset:us-ascii': 0.36; 'similar': 0.36; 'too': 0.37; 'being': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'happen': 0.63; 'become': 0.64; 'repeat': 0.74; 'end.': 0.84; 'subject:True': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: beginner question (True False help) Date: Thu, 8 Aug 2013 01:18:50 +0000 (UTC) References: <6c6dedec-5e47-4229-bc67-01b058cdb410@googlegroups.com> <7c627d74-a5c5-4356-9a04-9608de0006ba@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.31 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375924751 news.xs4all.nl 15977 [2001:888:2000:d::a6]:39633 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52157 eschneider92@comcast.net wrote: > What I wanted to happen is when the user typed something other than 'y' or 'yes' after being asked 'go again?', the batman==False line would cause the program to stop asking anything and say 'this is the end'. Instead, what is happening is that the program just keeps going. I figured that after defining the function (thingy(), repeat()), that the while statement would repeat until the 'go again' user input was something other than 'y' or 'yes', and the batman==False part of the repeat() function would cause the 'while batman==True' part to become False and end. You probably answered my question and I'm too dumb to see it, but that's a slight elaboration on my problem. When you assign a variable inside a function, it has no effect on a global variable with similar name. In order to make it change the global, you'd have needed the global declaration. Try this: var = 42 def myfunc(): var = 90 print "before:", var myfunc() print "after:", var Now, change the function, by adding a declaration: def myfunc(): global var var = 90 and the result will change. -- DaveA