-1

I was making a small game and for some reason this function won't work.

while InstructionsNeeded != 'no' or InstructionsNeeded != 'yes':
        print("please type yes or no")
        InstructionsNeeded = input("Welcome to Dice Brawl. Do you need instructions:")
        InstructionsNeeded = InstructionsNeeded.lower()

I offer the input before this in the code and it works perfectly fine. Also when I checked to see what the value was of InstructionsNeeded and it would read fine.

  • 1
    `InstructionsNeeded` cannot be both 'no' and 'yes' at the same time, so one of those ***or*** conditions is always true… Think it through. – deceze Jun 08 '21 at 12:38
  • "wont' work" in what sense? For example, you're currently missing an initial starting value for `InstructionsNeeded`. – 9769953 Jun 08 '21 at 12:38
  • 2
    I doubt very much it works fine. Your condition is always true, since no string can equal both `'no'` and `'yes'`. It should be `while ... and ...: – chepner Jun 08 '21 at 12:38
  • you probably just want to change `InstructionsNeeded != 'yes'` to `InstructionsNeeded == 'yes'` – David Kaftan Jun 08 '21 at 12:38

1 Answers1

1

Just change the or operator to and otherwise you end up with an infinite loop:

while InstructionsNeeded != 'no' and InstructionsNeeded != 'yes':
        print("please type yes or no")
        InstructionsNeeded = input("Welcome to Dice Brawl. Do you need instructions:")
        InstructionsNeeded = InstructionsNeeded.lower()
zanga
  • 612
  • 4
  • 20