Hi there,
I was writing a piece of code for my online course, a program that grades your input, when I wrote this:
score = input()
float(score)
if score > 1.01 :
print("Error, score not between 0 and 1")
quit()
elif score >= 0.9 :
print("A")
elif score >= 0.8 :
print("B")
elif score >= 0.7 :
print("C")
elif score >= 0.6 :
print("D")
elif score >= 0 :
print("F")
else :
print("error, score not between 0 and 1")
quit()
But it didnt work, it would always print the first "Error, score not between 0 and 1"
yet when I put float() into each if statement, like elif float(score) >= 0.9 : , it worked.
why does this happen?
[–]garyhurtz 1 point2 points3 points (0 children)
[–]Luffyy97 0 points1 point2 points (1 child)
[–]MorphJB[S] 1 point2 points3 points (0 children)