Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

Illustration of Python for-else loop control flow showing break skipping else block
Python

Python for-else: How It Works and When to Use It

Understand Python's for-else construct: the else block runs only when the loop completes without break, with practical examples and common pitfalls.

for-elsepython loopsbreak statementcontrol flow
Diagram showing a loop with an else block that runs only when no break occurs.
Python

Python Loop Else: How For and While Else Clauses Work

Understand how Python's for and while else clauses work: they run only when the loop finishes without a break. Includes practical search and validation examples.

pythonfor-elsewhile-elsecontrol flow
Editorial diagram contrasting Python's pass statement, a no-op placeholder, with continue, which advances a loop to its next iteration.
Python

python pass vs continue: When to Use Each

python pass vs continue: Compare Python's pass and continue: what each does, where they differ in loops, and which fits placeholders, exception handlers, and iteration...

pythoncontrol-flowloopscode-readability
Diagram showing break exiting a loop and continue skipping an iteration in Python.
Python

Python Break vs Continue: Loop Control Explained

Python's break statement exits a loop immediately, while continue skips to the next iteration. Learn the difference, see examples for for and while loops, and know when to use each.

Python loopscontrol flowbreak statementcontinue statement
Illustration of a Python pass statement as a placeholder in code blocks
Python

Python Pass Statement: Syntax and Use Cases

python pass statement: Learn how the Python pass statement works, when to use it as a placeholder, and how it differs from continue and return.

pythonpass statementplaceholdercontrol flow
Illustration of a Python loop with a continue statement skipping an iteration
Python

Python Continue Statement: Skip Loop Iterations

Learn how Python's continue statement skips loop iterations, when to use it, and how it differs from break and pass.

Python loopscontinue statementcontrol flowfor loop
Illustration of a Python break statement exiting a loop early, represented by a break in a circular flow.
Python

Python break Statement: Controlling Loop Execution

Understand how Python's break statement exits for and while loops, interacts with else clauses, and behaves in nested loops, with practical code examples.

loop controlbreakcontrol flowpython loops
Diagram of two nested while loops with counters and break/continue labels
Python

Python Nested While Loops: Syntax, Behavior, and Pitfalls

Learn how to write and control nested while loops in Python, including break/continue behavior, common pitfalls, performance tradeoffs, and when to use a for loop instead.

pythonwhile loopnested loopscontrol flow
Illustration of a nested for loop in Python showing two loops, one inside the other, with a grid of coordinates representing iterations.
Python

Python Nested For Loop: Syntax and Performance

Practical guide to python nested for loops: syntax, use cases, performance implications, and how to avoid common mistakes.

Pythonloopsiterationperformance
Illustration comparing Python for and while loops with a decision path
Python

Python for vs while: Choosing the Right Loop

Compare Python for and while loops, learn when each is appropriate, and avoid common iteration pitfalls.

Python loopsfor loopwhile loopiteration