Super-newbie needs help!

Daniel Klein danielk at aracnet.com
Wed Nov 28 21:49:13 EST 2001


Without looking at any of the responses so far, this is what I've come
up with...

while 1:
        try:
                sum = int(raw_input("Enter your number: "))
        except ValueError:
                print "You did not enter a number!"
        else:
                if sum < 100:
                        print "You haven't reached 100 yet!
                        continue
                else:
                        break

Hope this helps,
Daniel Klein


On 28 Nov 2001 09:50:00 -0800, snowcrash3 at hotmail.com (SnowCrash)
wrote:

>Hello all,
>Let me just preclude this posting by saying i am a Web Designer who's
>decided that she wants to learn programming, and this is my first stab
>at it. i don't pretend to understand what i am doing. Thats what you
>guys are here for.
>
>Anyhow, i am reading through this nice tutorial provided at
>hetland.org, called "instant hacking". Just the basics on Python. i am
>presented with my very first exercise, and am stuck--
>"Write a program that continually reads in numbers from the user and
>adds them together until the sum reaches 100. "
>
>Now, i have some code:
>total = 100
>sum = input ("Enter your number.")
>while sum < total:
>	print "You haven't reached 100 yet!"
>	sum = input ("give me another number") + sum
>
>print "Ok, you got me!"
>
>HUH? i don't think its right, i've changed it about 4 times before
>posting it, and i've downloaded the Python 2.2 but can't seem to
>figure out how to use the thing to check my code. i know its WILDLY
>simple and feel like "well, gee, if i can't understand this much, then
>i should quit before i feel REALLY stupid", but i am just going to
>keep on truckin'....Hopefully with some help from comp.lang.python.
>
>Thanks in advance,
>-snow-





More information about the Python-list mailing list