count = 0
sum = 0
while True:
a = int(input())
sum=sum + a
count += 1
sum = 0
while True:
a = int(input())
sum=sum + a
count += 1
print(sum/count)
采用了while无限循环的语句,不然不知道加多少次。count是用来计数的。
这个样子写就比较好了
count = 0
sum = 0
while True:
a = int(input())
if a =="quit":
break
sum=sum + a
count += 1
print(sum/count)