Bradly
 
I'm new to python also.  Have you come across any good exercises that a beginner try.
 
I've spend some time going throught the many available turorials, but find it hard to get good exercises to try out what you learn.
 
Catherine

 
On 1/21/06, Bradly McConnell <[EMAIL PROTECTED]> wrote:
Greetings all:

I'm new to Python, and have come across and exercise that basically
counts to 100.  The idea is to accept user input for an initial
number, and then let the user add additional numbers.  I wanted to
give feedback if a number selected would bring the total above 100, so
the user would select a lower number.  It looks like I have it
working, but it doesn't seem very efficient.  I would like any hints,
help, or comments that you can provide.  Below is what I have so far.

number = input("Please enter a number: ")
while number != 100:
   additional_number = input("Please enter an additional number: ")
   if additional_number + number > 100:
       lower_number = input("please enter a lower number: ")
       if lower_number + number > 100:
           lower_number = input("Lower!")
       else:
           number = lower_number + number
   elif additional_number + number < 100:
       number = additional_number + number
   else:
       continue

print "Done", number


Brad
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to