Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76767
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Very basic question. How do I start again? |
| Date | 2014-08-21 22:18 -0400 |
| Message-ID | <6q9dv95mpcjrmu7uahltpq6mu2nt7is2en@4ax.com> (permalink) |
| References | <1e5dv9l3aik5bb1jn4vil731rdl7q6sl3l@4ax.com> <mailman.13269.1408672684.18130.python-list@python.org> |
| Organization | Unlimited download news at news.astraweb.com |
On Fri, 22 Aug 2014 11:58:00 +1000, Chris Angelico <rosuav@gmail.com> wrote: >On Fri, Aug 22, 2014 at 11:37 AM, Seymore4Head ><Seymore4Head@hotmail.invalid> wrote: >> I want to give the computer 100 tries to guess a random number between >> 1 and 100 picked by the computer. >> > >Suggestion: Be up-front about this being a homework assignment. Most >of us can tell anyway, and it's more honest that way :) > >So, since this is homework, I'm not going to give you the answer. What >I'll do is point you in the direction you need to go. > >The most important problem isn't in your code, it's actually here: > >> The program fails when guess=pick > >In Python, a program doesn't simply fail. It might do the wrong thing >(in which case you should tell us both what it does and what you >expect it to do), or it might terminate with an exception traceback. >Those tracebacks are incredibly useful; when you're asking for help >with a failing program, pasting the entire traceback, including the >full error message, is extremely helpful. > >In this case, though, what I'm seeing is that the program will >errantly keep looping when it gets it right. (Not infinitely as you >have the "count < 100" check, but it still loops more than it should.) >So what you need to do is tell it to stop looping when it gets the >right guess. Do you know how to do that? > >ChrisA No homework. This is just for personal enrichment. Stopping the program when guess==pick is not really what I want the program to do, but it that is what I am limited to do, that will have to do. I am also unable to get that working at the moment. More trial and error with the break statement is what I will be doing next. Thanks
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Very basic question. How do I start again? Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-21 21:37 -0400
Re: Very basic question. How do I start again? Ben Finney <ben+python@benfinney.id.au> - 2014-08-22 11:55 +1000
Re: Very basic question. How do I start again? Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-21 22:13 -0400
Re: Very basic question. How do I start again? Chris Angelico <rosuav@gmail.com> - 2014-08-22 12:24 +1000
Re: Very basic question. How do I start again? Chris Angelico <rosuav@gmail.com> - 2014-08-22 11:58 +1000
Re: Very basic question. How do I start again? Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-21 22:18 -0400
Re: Very basic question. How do I start again? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-08-21 23:17 -0400
Re: Very basic question. How do I start again? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-22 12:58 +1000
Re: Very basic question. How do I start again? Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-22 04:26 +0000
Re: Very basic question. How do I start again? Tim Roberts <timr@probo.com> - 2014-08-21 22:56 -0700
Re: Very basic question. How do I start again? Igor Korot <ikorot01@gmail.com> - 2014-08-21 23:21 -0700
csiph-web