Beginner Programmer Question

Claudio Grondi claudio.grondi at
Mon Jun 26 20:09:20 CEST 2006

kydavis77 at wrote:
> kydavis77 at wrote:
>>Claudio Grondi wrote:
>>>kydavis77 at wrote:
>>>>I am doing alot of reading and trying to teach myself how to program.
>>>>I can not figure out how to make "Write a program that continually
>>>>reads in numbers from the user and adds them together until the sum
>>>>reaches 100." this work. If someone could show me the correct code so i
>>>>can learn from that it would be much appreciated. Thanks
>>>Isn't it your homework?
>>>Why can't you figure it out?
>>>What have you tried?
>>I am doing alot of reading, and the problem didnt come with an answer.
>>I dont understand how to get it to continually input numbers and add
>>all those together
> #Add up to 100 program
> #What number are you adding up to?
> bigone = 100
> number = input("Whats the first number?")
> number2 = input ("Whats the second number?")
> nu3 = number+number2
> while nu3 < bigone:
  # you are missing the input and building the sum here:
    number3 = input ("Whats the next number?")
    nu3 = nu3 + number3
>     print ("Not there yet, next number please")
  # so nu3 gets never changed and your loop runs forever.
> print "Finally there!"
> thats what i thought maybe it was...but after the first two numbers it
> just continually scrolls on the screen with finally there
Yes, because you have no input command in the loop and no sum changing 
the value of nu3.
But you should get scrolling with "Not there yet, next number please" 
not with "Finally there!" according to your code.

I suppose your next question will be what tutorial is the best for a 
newbie, so I suggest you start with:


More information about the Python-list mailing list