Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:help': 0.08; '"__main__":': 0.09; '__name__': 0.09; 'main()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stack.': 0.09; 'subject:question': 0.10; 'python': 0.11; 'def': 0.12; "(i'm": 0.16; 'ans': 0.16; 'email addr:comcast.net': 0.16; 'main():': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:> 20': 0.16; 'subject:beginner': 0.16; 'true:': 0.16; 'aug': 0.22; 'print': 0.22; '2.x': 0.24; 'url:home': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; '3.x': 0.31; 'libraries': 0.31; 'run': 0.32; 'fri,': 0.33; 'subject: (': 0.35; 'charset:us- ascii': 0.36; 'to:addr:python-list': 0.38; 'does': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'eventually': 0.60; 'most': 0.60; 'break': 0.61; 'more': 0.64; 'repeat': 0.74; 'again?': 0.84; 'recursion:': 0.84; '"how': 0.91; 'subject:True': 0.91; 'received:108': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: beginner question (True False help) Date: Fri, 09 Aug 2013 22:58:40 -0400 Organization: IISS Elusive Unicorn References: <6c6dedec-5e47-4229-bc67-01b058cdb410@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-68-178-245.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376103528 news.xs4all.nl 15893 [2001:888:2000:d::a6]:39142 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52293 On Fri, 9 Aug 2013 15:27:50 -0700 (PDT), eschneider92@comcast.net declaimed the following: >This is what I ended up with btw. Does this insult anyone's more well attuned Python sensibilities? > >letters='abcdefghijkl' >def repeat(): > print('wanna go again?') > batman=input() > if batman in ('y','yes'): > main() > else: > return >def main(): > print('guess a letter') > batman=input() > if batman in letters: > print('ok that letter was in letters') > repeat() > else: > print('asdasdasd') > repeat() >main() >print('how ya doin') You have recursion: repeat calls main and main calls repeat... Eventually you may fill the call stack. (I'm presuming Python 3.x -- I still run 2.x as some of the libraries I most rely upon have not yet been ported). Also the structure else: return is equivalent to just Let's see... (Untested) -=-=-=-=-=- letters='abcdefghijkl' def main(): while True: ltr = raw_input("Guess a Letter> ") if ltr.lower() in letters: print "OK, that letter was in 'letters'" else: print "asda is a UK grocery chain" ans = raw_input("Want to try again? ") if not ans.lower().startswith("y"): break if __name__ == "__main__": print "How ya doin'" main() -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/