0

Hey all I'm new to python and I'm just trying to make a program that asks for your name and if you put in the name "Joe" it says "Hi Joe" and if you put in something else it says " I don't know you. The problem is that i can type in any name and it still says "Hi Joe!" What did I do wrong?

print("what is your name?")
name = input()

if name == "joe" or "Joe":
    print("Hi Joe!")
else:
    print("I don't know you.")

input("press enter to exit")
Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
  • 5
    Possible duplicate of [How to test multiple variables against a value?](https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-against-a-value) – Barmar Jun 26 '18 at 00:49
  • You can think of it as `name == "joe"` or `"Joe"`. The latter (non-empty `str`) always evaluates as `True`. See the link in @Barmar 's comment for how to you could do such comparison. – Ondrej K. Jun 26 '18 at 01:14
  • Please note that indentation is very important in Python, so please ensure your posts are properly formatted; I have fixed it for now. – Ken Y-N Jun 26 '18 at 04:03

1 Answers1

0
print("what is your name?")
name = input()

if name.lower() == "joe": #will put everything lower case, also allows jOe 
    print("Hi Joe!")
else:
    print("I don't know you.")

input("press enter to exit")

Alternatively use if name == "joe" or name == "Joe:

Harvey251
  • 11
  • 1
  • 4