Indentation
Indentation is leading whitespace or spacing that positions content relative to its surrounding area and can represent hierarchy or structural nesting.
A Pythonic Adventure: From Python basics to a working web app
Indentation is leading whitespace that Python uses to delimit statement blocks and determine control structure.
- How it is used
- Uses indentation to define Python statement blocks while building a menu that repeatedly validates user input.
- How deep it goes
- Explains block membership and four-space layout through a while-loop correction, stopping short of deeper whitespace rules.
- Examples
- Demonstrates nested indentation in Erik’s menu function and practices finding errors with the editor’s Check button.
- What you can do after
- Diagnose missing-indentation errors with the editor’s Check button and apply correctly nested indentation to menu loops.
Read how A Pythonic Adventure: From Python basics to a working web app explains indentation →
The Quick Python Book, Fourth Edition
Whitespace placed at the beginning of source lines to visually align code and, in Python, delimit nested blocks.
- How it is used
- Delimits the bodies of Python conditionals, loops, and functions while keeping their structure visible.
- How deep it goes
- Explains block levels and nesting through examples, then addresses indentation errors and exceptions to the usual line layout.
- Examples
- Uses a factorial loop, an if-elif-else conditional, a nested function body, and erroneous unindentation.
- What you can do after
- Diagnose/debug with indentation levels to identify block membership and recognize common indentation errors.
Read how The Quick Python Book, Fourth Edition explains indentation →
Get Programming: Learn to code with Python
- How it is used
- Uses indentation to mark which Python statements belong to conditional and function code blocks.
- How deep it goes
- Explains four-space conditional indentation and compares nested with sequential decisions, then applies the same idea to function bodies.
- Examples
- Contrasts an indented conditional print with an unindented final print, and compares nested and unnested number checks.
- What you can do after
- Practice/perform indentation when writing conditional blocks, nested decisions, and function bodies in Python.
Read how Get Programming: Learn to code with Python explains indentation →
Learn AI-Assisted Python Programming, Second Edition
- How it is used
- Uses indentation to group statements while reading and writing Python functions, conditionals, and loops.
- How deep it goes
- Explains nested indentation levels and a behavioral error, without descending into interpreter internals.
- Examples
- Uses an hour-based greeting, larger-value function, word-scoring function, password checker, and nested country loops.
- What you can do after
- Diagnose/debug with it: identify misplaced Python statements and adjust indentation to preserve intended control-flow blocks.
Read how Learn AI-Assisted Python Programming, Second Edition explains indentation →
F# in Action: A Revised Edition of Get Programming with F#
Indentation is leading whitespace in source code that can delimit or structure blocks according to a language's syntax rules.
- How it is used
- Uses indentation to define F# scopes and make code structure readable without brace-heavy boilerplate.
- How deep it goes
- Explains indentation through function and local-binding layout, without detailing parser rules or complex nested constructs.
- Examples
- Demonstrates an arithmetic function with local bindings and a greeting function executed in F# Interactive.
- What you can do after
- Apply it via F# scripts to structure function bodies and limit local symbol visibility.
Read how F# in Action: A Revised Edition of Get Programming with F# explains indentation →
Fabulous Adventures in Data Structures and Algorithms
Indentation is horizontal whitespace used to indicate nesting or structural level in formatted source code.
- How it is used
- Improves source-code readability while a pretty printer lays out parsed expressions under line-width constraints.
- How deep it goes
- Defines indentation through formatting goals and implements it in grouped expression and parenthesis-list documents.
- Examples
- Uses conditional statements, comments, nested member access, and comma-separated call arguments to compare indentation choices.
- What you can do after
- Builds indentation rules into a C# document visitor that formats parse-tree expressions at a selected width.
Read how Fabulous Adventures in Data Structures and Algorithms explains indentation →
Related concepts
- loopconfigures · A loop is a programming control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- blockconfigures · A code block is a grouped region of code treated as a unit, with boundaries and scope or execution behavior determined by its language or context.
- functionconfigures · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- YAMLpart of · YAML is a human-readable data-serialization standard for representing structured data, including mappings, sequences, and scalar values.
- F# syntaxused by · F# syntax is the set of lexical and grammatical rules that determine how F# programs are written and parsed.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





