python輸入若干個0–100的成績?
平均分的編碼是:
numbers=[]
while True:
x=input('請輸入一個整數:')
try:
numbers.append(int(x))
except:
print('不是整數')
while True:
flag=input('繼續輸入嗎?(yes/no)')
if flag.lower()not in('yes','no'):
print('只能輸入yes或no')
else:
breakif flag.lower()=='no':
break
print(sum(numbers)/len(numbers))