Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

While loop only takes one condition

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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!

>Solution :

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 ?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading