-2

In the code below a validation check is attempted. However, even when the correct numbers are entered the program prints ("Invalid entry!...). The expected result is when numbers 1,2 and 3 are entered the program enters the correct IF loops and when anything other than these 3 numbers are entered the program enters the While Loop.

I have tried to use while not but that didn't meet my needs for multiple operations either. I also tried using any() but that didn't meet my needs because i was doing more than one operation.

    while Userchoice != "1" or Userchoice != "2" or Userchoice != "3":
      print("Invalid entry! Please make sure you are entering the number next to the option")
      Userchoice = input ("Enter your choice: ")
    if Userchoice == "1":
      print("To play the game you and your partner must authenticate yourselves")

What is the correct way to place multiple operations in a while loop? Thank you for your help! Screenshot of code.

Sh0ur
  • 1

1 Answers1

0

Does this do what you want?

Userchoice = input("Enter your choice: ")
while Userchoice not in ["1", "2", "3"]:
    print("Invalid entry! Please make sure you are entering the number next to the option")
    Userchoice = input("Enter your choice: ")
if Userchoice == "1":
    print("To play the game you and your partner must authenticate yourselves")

mapf
  • 1,906
  • 1
  • 14
  • 40