==
checks for equality , so you are trying to check if the string accept1
is equal to the tuple ("yes", "Yes", "no", "No")
, this would never be true. Hence you get the output - "That's not a valid answer!"
.
You should use in
operator to check if accept1
is equal to one of the elements of the tuple.
Other suggestions, you can use .lower()
to make the complete string lowercase to check, and use set
. Example -
while accept1.lower() not in {"yes", "no"}:
And your loop is wrong (You are trying to loop as long as the answer is valid, when you should be trying to loop till the answer becomes valid), it should be something like -
accept1 = input("Do you accept?")
while accept1.lower() not in {"yes", "no"}:
print ("That's not a valid answer!")
accept1 = input("Do you accept?")
print ("I see.")