如果我取出第一个if
语句,此代码可以正常工作。但是,我需要设定界限。我想让try
只在输入介于0和1之间时才会发生。任何人都可以告诉我哪里出错了?
try:
inp = raw_input ("Enter Score:")
grade = float (inp)
if 0 < grade < 1:
pass
if grade >= 0.9:
print "A"
elif grade >= 0.8:
print "B"
elif grade >= 0.7:
print "C"
elif grade >= 0.6:
print "D"
elif grade <= 0.6:
print "F"
except:
print "please enter a value between 0 and 1"