Skip to content

Unclear paragraph in Section 4.5 (else Clauses on Loops) of Tutorial #162770

Backlog

Description

@alovicious72

Documentation URL

https://docs.python.org/3/tutorial/controlflow.html#else-clauses-on-loops

Documentation

I find the following, relatively-recent addition to the Tutorial's section on "else Clauses on Loops" (Section 4.5) to be a little unclear:

One way to think of the else clause is to imagine it paired with the if inside the loop. As the loop executes, it will run a sequence like if/if/if/else. The if is inside the loop, encountered a number of times. If the condition is ever true, a break will happen. If the condition is never true, the else clause outside the loop will execute.

The last three sentences of that paragraph are clear and correct - but I am unclear what the author intended to clarify/illustrate using the first two sentences. For example, I do not see how paring the else with the "if" inside the loop would induce an execution sequence like if/if/if/else.

In my own opinion, the explanation of the prior code example is sufficient without this paragraph (or at least the first two sentences of it which I found troublesome to understand).

If I am simply missing something obvious, then I apologize for the nuisance of reviewing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docs

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions