请问要如何修改才能让打分在0-100分内不触发except
try:
#可能出现的错误代码
x=int(input("评委人数"))
assert x>2
except ValueError:
print("必须为整数")
except:
print("人数必须大于2")
a1=[]
for i in range(x):
try:
a=input("请输入第{}位评委的分数:".format(i+1))
assert a>=0 and a<=100
a1.append(a)
print(a1[i])
except:
print("打分请在0-100分内,请重新打分")
a=input("请输入第{}位评委的分数:".format(i+1))
max =a1[0]
min=a1[0]
for i in range (1,x):
if a1[i]>=max:
max=a1[i]
elif a1[i]<=min:
min=a1[i]
a1.remove(max)
a1.remove(min)
print(a1)
s=0
for i in range(x-2):
s+=int(a1[i])
average=s/(i+1)
print(round(average,1))