> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Continue Statement

The `continue` statement is a control flow mechanism in Python used exclusively within loop structures (`for` and `while`). When the Python interpreter encounters a `continue` statement, it immediately suspends execution of the current iteration, bypasses any remaining statements within the loop's body, and forces the loop to transition to the next iteration.

## Syntax

```python theme={"dark"}
continue
```

## Execution Mechanics

The exact behavior of `continue` depends on the type of loop it is executed within:

* **In a `for` loop:** The interpreter immediately calls the `__next__()` method on the loop's underlying iterator. If an item is returned, the loop begins the next iteration with the new value. If a `StopIteration` exception is raised (meaning the iterable is exhausted), the loop terminates.
* **In a `while` loop:** The interpreter jumps directly back to the loop's conditional header. The boolean expression is re-evaluated; if it evaluates to `True`, the loop body executes again. If `False`, the loop terminates.

## Structural Rules

1. **Scope:** `continue` can only be used syntactically within a loop block. Placing it outside of a loop raises a `SyntaxError: 'continue' not properly in loop`.
2. **Nesting:** In nested loop architectures, `continue` applies strictly to the **innermost** loop enclosing it. It does not affect the control flow of outer loops.
3. **Interaction with `try...finally`:** If a `continue` statement is executed within a `try` block, and that block has an associated `finally` clause, the `finally` block is guaranteed to execute *before* the interpreter proceeds to the next loop iteration.

## Execution Flow Visualization

**`for` Loop Flow:**

```python theme={"dark"}
for i in range(3):
    print(f"Start iteration {i}")
    if i == 1:
        continue
    print(f"End iteration {i}")


# Output:

# Start iteration 0

# End iteration 0

# Start iteration 1  <-- 'End iteration 1' is bypassed

# Start iteration 2

# End iteration 2
```

**`while` Loop Flow:**

```python theme={"dark"}
x = 0
while x < 3:
    x += 1
    print(f"Start iteration {x}")
    if x == 2:
        continue
    print(f"End iteration {x}")


# Output:

# Start iteration 1

# End iteration 1

# Start iteration 2  <-- Jumps back to 'while x < 3' evaluation

# Start iteration 3

# End iteration 3
```

**`try...finally` Flow:**

```python theme={"dark"}
for i in range(2):
    try:
        print(f"Try block {i}")
        continue
    finally:
        print(f"Finally block {i}")


# Output:

# Try block 0

# Finally block 0  <-- Executes before the next iteration begins

# Try block 1

# Finally block 1
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Python Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
