#๐ while loop won't break, even when the condition is met
44 messages ยท Page 1 of 1 (latest)
@faint cedar
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
How did you verify that the condition was met?
It's been a long day but aren't those conditions reversed?
ie in one it breaks when not matches color, in the other when it matches color
Would be a lot simpler using break imho ๐
Try adding that sleep to the one with if condition
just use a break with a if statement
the break will only break the while loop, not the for loop
and the pag.press
so you want to break the while loop right?
just put a if statement inside the while loop and if that statement is true it sould break
does it work if you comment out the pag.press
does it print the i can see it even once or not at all
does it even enter the for loop?
Have you confirmed that the code is reaching the for loop?
You want it to click if it matches the color?
Cuz now its clicking if it doesnt match the color
So if the color is present it skips to printing I can see it
Put multiple print calls - at the beginning of the for loop, then inside the while (and print pixel colour then as well)
wait a sec the print is not in the while loop :/
the main problem is we don't know what we are trying to help with X_X and what's the output its spamming or giving any error :<> and the problem u having with the while loop (except it breaking it)
so everything works??
Is there anything else above it that may influence it?

Maybe try adding some breakpoints and follow your code and/or manually check the condition?
Did you try somthing like this? (idk what am i doing)
for i in range(8):
pag.press(str(i+1)
t.sleep(.2
while True:
if not pag.pixelMatchesColor(960, 601, (198, 198, 198)):
pag.rightClick()
t.sleep(random.uniform(.2, .3))
break
print("I can see it")
what about something like this?
while True:
pag.rightClick()
t.sleep(random.uniform(.2, .3))
if pag.pixelMtchesColor(960, 601, (198, 198, 198)):
break
???
Try printing rgb values of that pixel
:o

How about this? man my head hurts lol the for loop XD
for i in range(8):
pag.press(str(i+1)
t.sleep(.2
if not pag.pixelMtchesColor(960, 601, (198, 198, 198)):
while True:
pag.rightClick()
t.sleep(random.uniform(.2, .3))
if pag.pixelMtchesColor(960, 601, (198, 198, 198)):
break
welp

for i in range(8):
pag.press(str(i+1)
t.sleep(.2)
while not pag.pixelMatchesColor(960, 601, (198, 198, 198)):
print(f"Failed to match because the color is {pag.pixel(960, 601)}")
pag.rightClick()
t.sleep(random.uniform(.2, .3))
print("I can see it")
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
