I have a simple program that converts numerical scores into letter grades, but the condition score_int >=0 and score_int <= 100
isn't working. It lets me put values < 0
and > 100
and not display error message 'Enter a valid number'. How come?
while True :
score_str = input('Enter your numerical score:')
try:
score_int = int(score_str)
score_int >= 0 and score_int <= 100 # this condition isn't working for some reason**
except:
print('Enter a valid number')
continue
if score_int >= 90 and score_int <= 100 :
print('A')
continue
elif score_int >= 80 and score_int < 90 :
print('B')
continue
elif score_int >= 70 and score_int < 80 :
print('C')
continue
elif score_int >= 60 and score_int <= 70 :
print('D')
continue
elif score_int <= 60 :
print('F')
continue
Expected the code to display error message for values <0 and >100