[Tutor] Is this overkill?

Bradly McConnell bradly.mcconnell at gmail.com
Sat Jan 21 16:09:42 CET 2006


On 1/21/06, Alan Gauld <alan.gauld at freenet.co.uk> wrote:
> number = input("Please enter a number: ")
> while number != 100:
>     additional_number = input("Please enter an additional number: ")
>     if additional_number + number > 100:
>         lower_number = input("please enter a lower number: ")
>
> you can just 'continue' here since the while loop asks for a new
> number anyhow. It xchanges the behaviour salightly in that it never
> allows a number that sums to more than 100 whereas you allow
> only two attempts.

Not sure where I went wrong, but at this point, I cannot get the count
to reach 100 unless I use something like 60 and 40 for the number a
additional_number inputs.  It seems that my variables are being
overwritten, but the "previous" additional number doesn't get added to
number before it happens.  This appears in both my original, and with
the modifications that you (Alan) suggested.

I think I worked on it a bit too much last night, and lost track of
what I tried and didn't try so I think I'll take a look through the
areas on loops and conditional statements again this evening and start
over "fresh".

Thanks for the help.

Brad


More information about the Tutor mailing list