Very basic question. How do I start again?

Seymore4Head Seymore4Head at Hotmail.invalid
Thu Aug 21 22:18:24 EDT 2014


On Fri, 22 Aug 2014 11:58:00 +1000, Chris Angelico <rosuav at gmail.com>
wrote:

>On Fri, Aug 22, 2014 at 11:37 AM, Seymore4Head
><Seymore4Head at 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



More information about the Python-list mailing list