While loop only takes one condition

Question:

The while loop command only takes one condition or it’ll ignore them entirely. The script ends up running the program infinitely.

You can clearly see that the loop doesn't stop even with blue = True

same thing here

I’ve tried running the keyboard condition as a variable.
I’ve also tried a variable counter (while i < 4) as one of the conditions with the same results.
Switching the conditions and putting them in parenthesis didn’t work either.

Is there any way to solve this issue?

Thank you in advance!

Asked By: X-void235

||

Answers:

If one of the 2 conditions is true then it keeps on looping.

In order to exit the loop both conditions MUST be false.
Meaning :

  • blue must be true
  • q must be pressed

Don’t know pyautogui and its is_pressed() behaviour. May be you’ve to keep the finger on the q key to satisfy the 2nd condition ?

Answered By: fbattello
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.