'Can I make if statement just for one use in loop?
Here's the code:
while 1:
if pyautogui.locateOnScreen('first323232.png', confidence=0.8) != None:
click(1021,881)
kibord()
time.sleep(2)
if pyautogui.locateOnScreen('grzonskie.png', confidence=0.8) != None:
rest()
if pyautogui.locateOnScreen('hp.png', confidence = 0.8) != None:
click(1132,50)
kibord()
time.sleep(1)
else:
continue
I want to make if pyautogui.locateOnScreen('grzonskie.png', confidence = 0.8) != None: rest() to be used just 1 time. How can i do this? I tried to make it work with break pass and continue statements but it didn't work or i don't know how to use it properly.
Solution 1:[1]
You can add some flag named 'reset' for example and init it to True, Then check your condition with 'and reset' in the end, if the condition is True you can set the 'reset' flag to False and the condition will never be True again (because anything and False is always False).
Good luck!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel |
