spawn wrote: > > Also, you never break out of your deepest loop, why are you using two > > nested infinite-loops anyway? > > > > Regards, > > Brett Hoerner > > Ummmmmm ..because I'm new to programming? Actually, they do end. If I > move my "guess" variable outside the outermost loop, then it becomes > infinte. I know, I tried it. > > You guys are fast! I'll reread my documentation and try a few more > thing (I kept telling myself that running_total and subotal don't need > to be different variables!) and see what I get. > > As for that last post (I don't remember your name), ummmmmm ... WOW! > This is BEGINNING Python. That looks far too advanced for me.
Try to think logically about how this has to be done. You need a variable that holds the running total. You need variable that holds user input. You need to add user input to running total and compare it to max value. First it's often a good idea to start with pseudo-code: loop: get input add input to running total if running total = goal, exit loop what you do instead: loop 1: get input subtotal = input loop 2: get input set running total to sum of first input and second input if running total = goal: print 'congratulations...' Not sure what you want to do if total gets over max value.. you want to subtract user's next input? Or just terminate? I think your mistake is that you tried to write code and use commands you read about in the manual before clearly understanding what you want the code to do. Instead of solving two problems one by one you try to solve two problems at the same time, which is tenfold as difficult. The first problem is understanding how the logic of program will work, and the second, how to use commands properly to carry out that logic. Which is fine, I make this mistake often enough.. Hope this helps.. I didn't want to write out a solution 'cause you'll learn better if you do it on your own. -Rainy -- http://mail.python.org/mailman/listinfo/python-list