Begginers Guide - Exrcise. Help me, plz!
Sean 'Shaleh' Perry
shalehperry at attbi.com
Sat Mar 16 16:12:43 EST 2002
On 16-Mar-2002 Jeffrey-man wrote:
> Hello, everybody!
> I'm a newbie and I'm just learning. I know, it's a stupid question, but I
> want to resolve it.
> Learning the Begginers Guide, I found an exercise. It tells me:
> "Write a program that continually reads in numbers from the user and adds
> them together until the sum reaches 100."
> Can anybody help me?
>
> -----
>
> sum_stop = 100
> num = input("Please enter the number: ")
>
> for sum in range(num+num,sum_stop):
> print "Now the sum is", num+num
> sleep(1)
>
> print "The sum is >/= 100!"
>
> -----
>
> Maybe I'm doing something wrong?
>
>
you misread the specification.
You are to ask the user "give me a number", add that number to the previous one
(hint: use zero the first time), then check if the new sum is less than the
stopping point (100 in this case). If the stopping point is reached, cease
asking for a number.
Does that help?
More information about the Python-list
mailing list