-1

I'm a beginner programer and am trying to write a program that will put users into their key stage in school based on their year. The answer may be very simple but I'm a beginner so I would really appreciate your help.

This is the code I've written for it:

 answer = int(input("What year are you in?"))
 if answer < 7 or 8 or 9:
     print("You are in Key Stage 3")
 elif answer < 10 or 11:
     print("You are in Key Stage 4")
 else:
     print("You are in Key Stage 5")

Year 7-9 is key stage 3, year 10-11 is key stage 4 and year 12-13 is key stage 5. The program is supposed to output 'key stage' 3, 4 or 5 depending on what the user put in. Whenever i put in any year it outputs key stage 3, even if I input '11' or '13' which it shouldn't.

khelwood
  • 55,782
  • 14
  • 81
  • 108
RynAl
  • 1

1 Answers1

0

Try this :

if answer in (7, 8, 9):
     print("You are in Key Stage 3")
elif answer in (10, 11):
     print("You are in Key Stage 4")
else:
     print("You are in Key Stage 5")

or this :

if 7 <= answer <= 9:
     print("You are in Key Stage 3")
elif 10 <= answer <= 11:
     print("You are in Key Stage 4")
else:
     print("You are in Key Stage 5")
Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56