New to Python
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Mon Mar 5 16:43:09 EST 2007
dnwurtz at gmail.com a écrit :
> 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. Here
> is what I have so far. I know I am just trying to hard, but I am
> stuck.
Where ?
May I suggest this reading ?
http://www.catb.org/~esr/faqs/smart-questions.html
> Thank you for any help.
>
> print "We need to count to 100"
>
> high_number = 100
> total = 0
>
> number = input("Enter your first number ")
Please re-read *very carefully* the doc for input(). Then switch to
raw_input() and perform appropriate validation and conversion.
> sum = number + total
don't use 'sum' as an identifier, unless you don't mind shadowing the
builtin sum() function.
> while sum < high_number:
> print "Not there yet..."
> number = input("Enter another number ")
>
> print "We are there!!!"
We're not. number won't be automagically added to sum.
More information about the Python-list
mailing list