Hi there,
im just having a hard time understanding why this code does not print anything that is suppose to print:
score = raw_input ('what is your score? \n')
try:
if 1.0 == float(score) >= 0.9:
print "A"
elif 0.9 > float(score) >= 0.8:
print "B"
elif 0.8 > float(score) >= 0.7:
print "C"
elif 0.7 > float(score) >= 0.6:
print "D"
elif 0.6 > float(score):
print "F"
except:
print "bad score"
whereas this other one does do the job correctly:
score = raw_input ('please provide a score between 0.0 and 1.0\n')
try:
if float(score) >= 0.9 and float(score) <= 1.0:
print "A"
elif float(score) >= 0.8 and float(score) < 0.9:
print "B"
elif float(score) >= 0.7 and float(score) < 0.8:
print "C"
elif float(score) >= 0.6 and float(score) < 0.7:
print "D"
elif float(score) < 0.6:
print "F"
except:
print "Bad score"
Any insight?
---------- Post updated at 08:55 AM ---------- Previous update was at 08:44 AM ----------
Ok, I got it, the right way to define a numerical range is as in the second option. But why then I dont get any error if the first code is not written properly?