第1个回答 2017-11-07
list1 = []
a = 1
while True:
if int(a) < 0:
break
else:
a = int(raw_input("Enter a number(<negative to quit>)"))
list1.append(a)
list2 = list1[:-1]
average = float(sum(list2)) / len(list2)
print ("The average of the numbers is %s" % average)