Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52293
| 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 | <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.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 <wlfraed@ix.netcom.com> |
| 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> <b9e1881e-dd26-497f-83d0-8884d08ec8ff@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 <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.416.1376103528.1251.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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
<end of procedure>
is equivalent to just
<end of procedure>
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/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
beginner question (True False help) eschneider92@comcast.net - 2013-08-07 01:17 -0700
Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-07 09:42 +0100
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-07 13:59 -0700
Re: beginner question (True False help) Dave Angel <davea@davea.name> - 2013-08-08 01:18 +0000
Re: beginner question (True False help) Larry Hudson <orgnut@yahoo.com> - 2013-08-07 19:49 -0700
Re: beginner question (True False help) wxjmfauth@gmail.com - 2013-08-07 23:20 -0700
Re: beginner question (True False help) Chris Angelico <rosuav@gmail.com> - 2013-08-08 12:41 +0100
Re: beginner question (True False help) Terry Reedy <tjreedy@udel.edu> - 2013-08-08 16:29 -0400
Re: beginner question (True False help) wxjmfauth@gmail.com - 2013-08-09 01:05 -0700
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 15:27 -0700
Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-10 00:05 +0100
Re: beginner question (True False help) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-09 22:58 -0400
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 15:28 -0700
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:14 -0700
Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-10 00:30 +0100
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:24 -0700
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:34 -0700
Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-10 02:22 +0100
Re: beginner question (True False help) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-10 01:40 +0000
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:40 -0700
Re: beginner question (True False help) MRAB <python@mrabarnett.plus.com> - 2013-08-10 01:39 +0100
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:43 -0700
Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 18:08 -0700
csiph-web