May-31-2018, 05:46 PM
I'm steaming fresh out of the oven new to Python and trying to teach it to myself using an online book. Based on the little I've learned, I'm trying to create a program that will ask the user to input their name and if the name is one of two names, it outputs one response. If the name isn't one of those names, it outputs a different response. For some reason, I'm only able to get one name to work (ie. if name = 'x' print), but when I try to add a second name using or (ie. if name = 'x' or 'y' print), then it just outputs whatever the user input rather than going to the else. Here's what I've got:
print('What is your name?') myName = input() if myName == 'Tom' or 'Jerry': print('Hello ' + myName) else: print('Hello Stranger')Am I not using the or operator correctly?