-3

I'm not sure what I'm doing wrong. I want to make it so that if the user enters a name which isn't of those specified the program should print the else statement at the bottom. I also want the elif statements to work so if the users enter their age then the correct print statement should show.

name = input("What is your name?")
if name == "Jean Gray" or "Max Eisanhardt" or "James Howlett" or "Anne Marie":
    age = int(input("How old are you?")
    if age <= 12:
    print ('You should be placed in the junior category because you are younger than 12 years old')
    elif age >= 18:
    print ('You should be placed in the senior category because you are older than 18 years old')
    elif age <=17:
    print ('You should be places in the teen category')          
else:
    print("Sorry, that name is not recognised.")
krlzlx
  • 5,752
  • 14
  • 47
  • 55
Ben
  • 21
  • 6
  • `if name == "Jean Gray" or "Max Eisanhardt" or "James Howlett" or "Anne Marie"`: This line is not doing what you think it does. Your testing if `name` equals each string. Your only testing if `name` equals `"Jean Gray"`. The other strings in the if statement are only tested for "truthiness". – Christian Dean Nov 12 '16 at 13:27

1 Answers1

-1

Your if statement will always currently evaluate to true, you should use the syntax

if a == "value1" or a == "value 2" or a == "value3":
  //do something
Jon Taylor
  • 7,865
  • 5
  • 30
  • 55