New to Python
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Mon Mar 5 13:51:59 EST 2007
dnwurtz at gmail.com wrote:
> I am trying to get a program to add up input from the user to get
> to the number 100 using a loop. However, I am having some issues.
Please, if you have a problem post the exact error symptoms.
> Here is what I have so far. I know I am just trying to hard, but
> I am stuck. Thank you for any help.
We can't tell by magic where you are stuck. Please state observed
and expected behaviour.
> print "We need to count to 100"
>
> high_number = 100
> total = 0
>
> number = input("Enter your first number ")
(already mentioned: please don't use input)
> sum = number + total
This is a one-time assignment.
> while sum < high_number:
> print "Not there yet..."
> number = input("Enter another number ")
>
> print "We are there!!!"
"We" won't reach this point since the while condition never becomes
False. See above; "sum" is assigned just one time and will not
change in your while loop. Having the program work as probably
expected requires a "sum += number" inside the while loop.
BTW, what's "total" expected to do? It's also assigned only one
time.
Regards,
Björn
--
BOFH excuse #150:
Arcserve crashed the server again.
More information about the Python-list
mailing list