Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76765
| References | <1e5dv9l3aik5bb1jn4vil731rdl7q6sl3l@4ax.com> |
|---|---|
| Date | 2014-08-22 11:58 +1000 |
| Subject | Re: Very basic question. How do I start again? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13269.1408672684.18130.python-list@python.org> (permalink) |
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
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