Basically you should fix this line:
if int(grade) > maximum:
because the result of input
is a string, not a number, so the wrong comparison is used.
Of course, you could (and should!) also properly check that user has entered an integer value, otherwise there will be a ValueError
.
try:
if int(grade) > maximum:
print("enter a value less than maximum")
except ValueError:
print("enter an integer value")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…