liveBook · Manning

Loop variable

A loop variable is a variable whose value represents, tracks, or controls the current iteration of a loop.

How 2 Manning books explain it

Get Programming: Learn to code with Python

A loop variable is a variable that receives successive items from a sequence during loop execution.

How it is used
Deploys loop variables to repeat a for-loop body across numeric sequences or string characters.
How deep it goes
Explains assignment and execution step by step, then contrasts automatic for-loop updates with manual while-loop control.
Examples
Uses range(3), character printing, string indices, counting exercises, and repeated-book messages as practice.
What you can do after
Apply it via Python for loops to process each number in a range or each character in a string.

Read how Get Programming: Learn to code with Python explains loop variable →

Learn Go with Pocket-Sized Projects

A loop variable is a variable whose value identifies or controls the current iteration of a loop.

How it is used
Protects values captured by goroutines launched inside loops.
How deep it goes
Explains the capture hazard and three protections, but does not develop loop-variable implementation internals.
Examples
Uses concurrent maze paths, channel messages, map and slice iteration, and parallel table tests.
What you can do after
Diagnose/debug with it by recognizing and preventing incorrect values captured by goroutines in loops.

Read how Learn Go with Pocket-Sized Projects explains loop variable →

Related concepts

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.