liveBook · Manning

Indentation

Also called indent

Indentation is leading whitespace or spacing that positions content relative to its surrounding area and can represent hierarchy or structural nesting.

How 6 Manning books explain it

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
Uses indentation to delimit Python function and control-flow bodies while making their structure visible.
How deep it goes
Explains block levels, nesting, style conventions, indentation errors, and continuation-line edge cases with concrete code.
Examples
Uses factorial loops and a function, conditional blocks, indentation errors, and continued strings to demonstrate layout.
What you can do after
Diagnose/debug indentation errors and structure Python function and control-flow blocks.

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 form F# scopes and mark function bodies.
How deep it goes
Defines indentation through scoping and demonstrates a function body, without detailing nested alignment rules.
Examples
Shows an indented greeting function and a multistep arithmetic function contrasted with verbose punctuation.
What you can do after
Practice/perform writing an indented F# function body and sending its definition to FSI.

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 →

Also covered in

What to know first

Related concepts

Questions about indentation

What is indentation?

Indentation is leading whitespace or spacing that positions content relative to its surrounding area and can represent hierarchy or structural nesting.

Which Manning books explain indentation?

A Pythonic Adventure: From Python basics to a working web app, The Quick Python Book, Fourth Edition, Get Programming: Learn to code with Python, Learn AI-Assisted Python Programming, Second Edition, F# in Action: A Revised Edition of Get Programming with F# and Fabulous Adventures in Data Structures and Algorithms.

What should I know before learning indentation?

Manning books that teach indentation usually introduce conditional logic, string, loop and block first.

What is indentation part of?

Indentation is part of YAML. YAML is a human-readable data serialization standard for representing structured data, commonly using indentation to express mappings and sequences.

What is indentation also called?

Indentation is also called indent.

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.