The following code snippet is meant to allow the user to input the answer to a question. They are allowed to enter four
answers: either y
or Y
for “yes”, or n
or N
for “no”. The program is supposed to print out the received answer if the
entry is valid, and print out an error message otherwise.
answer = input("What is your answer? ")
if answer == "y" or "Y":
print("You answered yes")
elif answer == "n" or "N":
print("You answered no")
else:
print("You didn’t enter an acceptable answer")
It just keeps on saying that I answered yes
regardless if I put n
or N
or some random thing. Can someone explain it to me?