Please help - get average

Terry Reedy tjreedy at udel.edu
Wed Oct 27 13:25:44 EDT 2004


Message
"Borman, Linda E" <LBorman at sjm.com> wrote in message 
news:743AC0214781BD40ABFCC53FEA5FA134D19CC4 at usmtml01.ad.sjm.com...

Please post using plain ascii text instead of html.  With the latter, it is 
difficult to insert comments that look like comment where they belong.

# using for loop
number = 10
while number !=0 :
    number = input("Enter a number: ")

Your first error is here: you are using 'number' as both a loop control 
variable and a data input variable.  So the loop will continue until 
someone enters a 0.
Also, never use input in a program others will use until you understand why 
it is dangerous.  So, replace above with something like

   n = int(raw_input('Enter an integer: '))

Terry J. Reedy






More information about the Python-list mailing list