Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goto, but why? correction #356

Open
62830 opened this issue Nov 21, 2024 · 2 comments
Open

goto, but why? correction #356

62830 opened this issue Nov 21, 2024 · 2 comments

Comments

@62830
Copy link

62830 commented Nov 21, 2024

Hi,

If I'm not mistaken, I think the "goto, but why?" section missed one I am trapped, please rescue! Can you help double check it? (or am I missing some April Fool's joke?)

The code is

from goto import goto, label
for i in range(9):
    for j in range(9):
        for k in range(9):
            print("I am trapped, please rescue!")
            if k == 2:
                goto .breakout # breaking out from a deeply nested loop
label .breakout
print("Freedom!")

The output should be

I am trapped, please rescue!
I am trapped, please rescue!
I am trapped, please rescue!
Freedom!

Instead of

I am trapped, please rescue!
I am trapped, please rescue!
Freedom!
@Ponnshe
Copy link

Ponnshe commented Nov 23, 2024

Hi! I’ve double-checked the code and the explanation in the "goto, but why?" section.

You are correct—the expected output in the documentation is missing one I am trapped, please rescue!. The correct output should be:

I am trapped, please rescue!
I am trapped, please rescue!
I am trapped, please rescue!
Freedom!

The missing line occurs because the print("I am trapped, please rescue!") statement is executed three times (for k = 0, 1, 2) before the goto statement breaks out of the loop. It seems like a simple oversight in the documentation.

@nifadyev
Copy link
Contributor

Hey @62830 , thanks for discovering an issue. Do you wish to make the changes? We are in progress of redesigning wtfpython and you could help us a lot.

Here are some examples you could use to make the changes - snippet in README snippet add line in noxfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants