score=int(input("请输入一个0—100的数:"))
degree="ABCDE"
num=0
if score>100 or score<0:
score=int(input("输入错误,请重新输入一个0-100的数:"))
else:
num=score//10
if num<6:
num=5
elif num==10:
num=9
print("分数是{0},等级是{1}".format(score,degree[9-num]))
请输入一个0—100的数:111
输入错误,请重新输入一个0-100的数:100
Traceback (most recent call last):
File "G:/Python编程/mypyoq/mypy06.py", line 28, in <module>
print("分数是{0},等级是{1}".format(score,degree[9-num]))
IndexError: string index out of range
为啥输入错误一次后就不能再次进行判断了,会出现超出索引范围