If with input and or

How to get the answer of input and execute a code according to the answer with if ?

Example :

if input(“a”) == “yes”:
print(“b”)
else:
print(“c”)

Here if I answer yes it prints me “b” and if not it prints me “c”. But if the code is like this :

if input(“a”) == “yes” or “no”:
print(“b”)
else:
print(“c”)

It always writes me “b”, whatever my answer.

Can you help please ?

Please wrap code in triple backticks to preserve the formatting:

```python
if True:
    print(''Hello world!')
```

input("a") == "yes" or "no" is equivalent to (input("a") == "yes") or "no", and "no" will be treated as true, so that condition will always be true no matter what you input.

What you should write instead is something like input("a") in {"yes", "no"}.

It would also be a good idea to convert what’s input to lowercase because “YES” != “yes”.

Thank you so much, this is very helpful.