New to coding, having problems making foolproof input for program:
answer=input(x)
while (answer != "yes") or (answer != "no"):
answer=input("must be 'yes' or 'no' answer")
The while loop never stops, regardless of input. What am I doing wrong?
Here is what I would use:
while answer not in ("yes", "no"):
Right now, your code is running continually because answer will always be not "yes" or not "no".
Also, if you want, you can add .lower() like so:
while answer.lower() not in ("yes", "no"):
This will allow your code to handle inputs such as "Yes", "yEs", etc.
Everything is either not yes or not no. You want and.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With