+ 1

Why is my while statement at the end repeating the text "Huh?" as the output infinitely?

Whenever my while statement runs, it repeats infinitely. Also, my while statement will run unnecessarily. Why? .....Spam = input('Man, I hate that one show, "Deer Circus". Do you? ') if Spam == "yes" or Spam == "Yes" or Spam == "YES": print("I know, right!") elif Spam == "no" or Spam == "No" or Spam == "NO": print("Well, to each's own, I guess.") Spam = "" while Spam != "yes" or Spam != "Yes" or Spam != "YES" or Spam != "no" or Spam != "No" or Spam != "NO": print("Huh?")

15th Aug 2017, 9:23 PM
John
1 Resposta
+ 1
you emty Spam, then you give a statement that is true and you dont change the Spam var inside the body of the loop, so it can never escape from it resulting an infinite loop. I think that the "if" keyword is the most suitable in the place of the "while" keyword
15th Aug 2017, 9:37 PM
EagleEye
EagleEye - avatar