-2
userans = input("Do you want to become a member of Friends of Seaview Pier? ").lower()
while not (userans == "yes" and "no"):
  userans = input("Do you want to become a member of Friends of Seaview Pier? ").lower()
  print (userans)
if userans == "yes":
  Appdata = Application()
  userans2 = input("Do you want to volunteer at Seaview Pier? ").lower()
  if userans2 == "yes":
    Vdata = Volunteerdata()
    CombinedData = [Appdata, Vdata]
    Data.append(CombinedData)
    print(Data)
  else:
    print("Thank you for considering.")
    Vdata = (["no"])
    CombinedData = [Appdata, Vdata]
    Data.append(CombinedData)
    print(Data)
elif userans == "no":
  print("Thank you for your consideration.")

There are a few print functions in there just so I can check what it going in and coming out as it runs. I also haven't included the functions i made for the sake of convenience, as I'm pretty sure this is as issue with this bit of code here and not them.
An example of the output and input is below:

Do you want to become a member of Friends of Seaview Pier? no
Do you want to become a member of Friends of Seaview Pier? no
no
Do you want to become a member of Friends of Seaview Pier? on
on
Do you want to become a member of Friends of Seaview Pier? no
no
Do you want to become a member of Friends of Seaview Pier? yes
yes
Enter your first name:
Felix
  • 3
  • 1
  • Let's say that `userans = "no"` -- so `userans == "yes"` evaluates to `False`, and `False and "no"` is `False`. – Charles Duffy Feb 21 '22 at 17:28
  • The part `"no"` in your while condition `(userans == "yes" and "no")` always translates to True. `if "no": print("is true")` Output: `is true` You could change the condition to `while not (userans == "yes" or userans == "no")` to exit the while loop in case a "yes" or "no" was inputed by the user. – Christian Weiss Feb 21 '22 at 17:36

1 Answers1

-1
while not (userans == "yes" and "no")

That is the wrong way to check for multiple values.

Use this instead:

while userans != "yes" and userans != "no":

Or even better:

while userans not in ["yes", "no"]:
John Gordon
  • 29,573
  • 7
  • 33
  • 58
  • (Not my downvote, but:) Per the _Answer Well-Asked Questions_ section of [How to Answer](https://stackoverflow.com/help/how-to-answer), questions that have been "asked and answered many times before" should be closed, not answered. – Charles Duffy Feb 21 '22 at 17:29