-3

If I run this using 'or' down there in the if statement it dose not matter what name I provide for the input, everything makes the function run. If I remove the or then the if statement runs and the elif and else are ignored.

   names = ['Luke', 'James', 'Bob', 'Rob', 'Vincent']
    emp_name = input("What is your name?")

    def employees():
        for name in names:
            if name == 'Luke':
                print(name, '- is the best')
                continue
            if name == 'Vincent':
                print(name, '- is insane')
                continue
            print(name, '- is okay')


    if emp_name.lower() == "luke e. hayes" or "luke":
        employees()
    elif emp_name.lower() != "luke e. hayes" or "luke":
        print("Get out")
    else:
        print("Error")
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Don't know how to edit this post. What I wanted to say was if the or is removed the if statement only runs if I provide luke e. hayes or luke for the input and the elif gets triggers if I provide another name. With the or there the if statement gets triggers no matter what name I provide. – Luke Hayes Aug 17 '17 at 21:49

1 Answers1

0

The issue is your if statement, you're actually evaluating name=="luke e.hayes" or "luke" . "luke" will always evaluate to true since it has a value. Try

if emp_name.lower() == "luke e. hayes" or emp_name.lower() == "luke":

You will run into the same eact issue on the next line which should be converted to

 elif emp_name.lower() != "luke e. hayes" and emp_name.lower() !="luke":

The second one should print no matter what and you will want to use an and statment there. Let me know if you need more of an explanation

Lucas Hendren
  • 2,786
  • 2
  • 18
  • 33