Reputation: 13
score = input("What is your score? ")
if score == str(100):
print('Perfect!')
elif score <= str(range(95, 99)):
print('Great!')
elif score <= str(range(90, 95)):
print('Good')
else:
print('Fail')
It works when I type 95 to 100, but it doesn't work when I type other numbers.
Upvotes: 0
Views: 66
Reputation: 8946
Use ints to compare numbers, not strings:
score = int(input("What is your score? "))
if score == 100:
print('Perfect!')
elif score in range(95, 100): # This 100 catches the 99 case
print('Great!')
elif score in range(90, 95):
print('Good')
else:
print('Fail')
Upvotes: 6