#π The code works but idk how
29 messages Β· Page 1 of 1 (latest)
@shrewd thicket
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.
no, its working as i want it to, but there is no corrosponding if, exactly my problem
so for loops have else?
No they don't
They do have else π
if i indent, the logic changes giving me a differnt output than i want
Just not commonly used
well, that expalins it
!e
for _ in range(2):
print("stuff")
else:
print("For-Else runs when the for block is done executing")
@vivid flicker :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | stuff
002 | stuff
003 | For-Else runs when the for block is done executing
but how does it decide to run or not?
Note: The else block will NOT be executed if the loop is stopped by a break statement.
if the for loop "breaks" the else doesnt run, if it doesnt break, the else runs.
But that aside, your issue probably is that you wanted it on an if statement somewhere π
Let me have al ook
nope, its exactly what i wanted
Ah okay π Good stuff
!close
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.