Loop
A loop is a programming control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
Tiny Python Projects: Learn coding and testing with puzzles and games
A while loop is a Python control-flow construct that repeatedly executes a block while its condition is true.
- How it is used
- Processes characters, lines, files, generated ranges, and function inputs in small Python programs.
- How deep it goes
- Explains iteration, accumulation, nesting, range control, and refactoring, but does not descend into interpreter internals.
- Examples
- Uses text translation, ransom capitalization, file counting, random insults, song verses, and manual CSV parsing.
- What you can do after
- Build it from scratch, process iterable values, accumulate transformed results, nest loops, and refactor tested loops into comprehensions or map.
Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains loop →
Learn AI-Assisted Python Programming, Second Edition
A loop is a programming construct that repeatedly executes a block of code while iterating over values or while a condition holds.
- How it is used
- Processes each value in a known string or list while teaching readers to recognize common Python code.
- How deep it goes
- Explains loop variables, iterations, indentation, range, indexes, nesting, and contrast with while loops, but not implementation internals.
- Examples
- Uses letters, animals, word scoring, password characters, country pairs, Olympic medal lists, and list indexes.
- What you can do after
- Apply it to iterate through sequences, process list indexes, nest repetition, and identify indentation or infinite-loop errors.
Read how Learn AI-Assisted Python Programming, Second Edition explains loop →
Get Programming: Learn to code with Python
A loop is a control-flow construct that repeatedly executes a code block while iterating over values or satisfying a continuation rule.
- How it is used
- Uses loops to replace repeated statements with concise code for tasks performed a known number of times or until a condition changes.
- How deep it goes
- Traces loop-variable values, custom ranges, condition checks, and infinite-loop risks; stops at introductory Python examples.
- Examples
- Uses repeated printing, dice rolls, a word-guessing game, and letter tiles to show repetition in action.
- What you can do after
- Build it from scratch: write Python `for` and `while` loops, choose between them, and avoid a condition that never changes.
Read how Get Programming: Learn to code with Python explains loop →
100 Java Mistakes and How to Avoid Them
A for loop is a Java loop statement with initialization, condition, and iteration components that controls repeated execution.
- How it is used
- Controls repeated Java execution while framing common range, direction, termination, and iteration mistakes.
- How deep it goes
- Explains range direction, bounds, overflow, iterator behavior, tests, and tool diagnostics without specifying loop bytecode internals.
- Examples
- Uses descending ranges, inclusive maximum bounds, mutated ArrayLists, Stream pipelines, and tail-recursive string search.
- What you can do after
- Diagnose/debug with it by testing boundaries, spotting direction mismatches, and choosing safer iteration forms.
Read how 100 Java Mistakes and How to Avoid Them explains loop →
Clojure: The Essential Reference
A loop is a language construct that repeatedly evaluates a body while passing through successive control states or values.
- How it is used
- Contrasts value-producing iteration through immutable bindings with mutable Java for-loops and side-effecting while loops.
- How deep it goes
- Explains loop bindings, recur targets and tail-position requirements, then distinguishes while’s test-and-body contract.
- Examples
- Works through squared numbers and Fibonacci, alongside stream hashing, a status thread, and sequence-based printing.
- What you can do after
- Build it from scratch with loop/recur, or choose while for side-effecting tests and sequence operations for ordinary iteration.
Python How-To
A while loop repeatedly executes a block of code while a Boolean condition remains true.
- How it is used
- Repeats operations while a condition remains true or across items in an iterable.
- How deep it goes
- Works through condition checks, iterator exhaustion, early exit, and loop `else`, then gives maintainability guidance.
- Examples
- Uses a changing counter, task searches, and nested product-option generation.
- What you can do after
- Practice/perform repeated work with `while` or `for`, and stop a search once a match appears.
Modern C, Third Edition
A for statement is a C iteration statement that controls repeated execution using initialization, a continuation condition, and an iteration expression.
- How it is used
- Uses `for` to repeat a body across an iteration domain and to express condition-controlled repetition.
- How deep it goes
- Explains clause order, condition checks, counter scope, countdowns, and `break` and `continue`, then examines progress without deriving compiler internals.
- Examples
- Shows array output, three counter variations, and a bounded numerical approximation loop.
- What you can do after
- Practice/perform domain iteration with a locally declared counter, and check a loop's termination and observable progress.
Design for Developers
A design approach that repeatedly tests, evaluates, and refines a product through successive cycles.
- How it is used
- Guides website and web-application work from a user problem through research, design, building, testing, and refinement.
- How deep it goes
- Explains a phased workflow and feedback-driven restarts, while deferring detailed methods for individual test types.
- Examples
- Uses a web application tested only near launch to show how skipped research causes navigation problems, redesign, and delay.
- What you can do after
- Apply it to plan feedback cycles, test assumptions earlier, and refine websites or web applications around user needs.
Julia as a Second Language
A loop is a programming construct that repeatedly executes code while a specified condition remains true or until a termination condition is met.
- How it is used
- Uses loops to repeat calculations across inputs, from trigonometric tables to Fibonacci numbers.
- How deep it goes
- Works through while conditions and stepped for-loop ranges, then identifies collection iteration methods without implementing them here.
- Examples
- Demonstrates printed ranges, stepped angles, iterative factorial, and Fibonacci calculations.
- What you can do after
- Build it from scratch: write condition-controlled and range-based loops that update state and terminate.
Python Workout: 50 ten-minute exercises
A loop is a control-flow construct that repeatedly executes a block of code.
- How it is used
- Deploys direct iteration for input-driven exercises, string processing, file analysis, and commands with side effects.
- How deep it goes
- Explains direct item iteration, enumerate, side effects, and alternatives through multiple exercises, but does not cover loop internals.
- Examples
- Uses a guessing game, Pig Latin translation, file statistics, filename creation, word lengths, and indexed alphabet output.
- What you can do after
- Apply it to process iterable items, accumulate results, perform side effects, and select comprehensions for transformations.
Read how Python Workout: 50 ten-minute exercises explains loop →
Learn Go with Pocket-Sized Projects
A for loop is Go's looping construct for repeatedly executing a block with optional initialization, condition, and post-iteration expressions.
- How it is used
- Deploys iteration across slices, arrays, maps, output routines, and table-driven tests.
- How deep it goes
- Defines counted, conditional, infinite, and range forms, including index and value selection, without deeper runtime internals.
- Examples
- Demonstrates book-list printing, bookworm comparison helpers, and map-driven test cases.
- What you can do after
- Apply it via Go syntax to repeat work, traverse collections, print results, and compare structured test data.
Read how Learn Go with Pocket-Sized Projects explains loop →
Kotlin in Action, 2E
A loop is a control structure that repeatedly executes a block of code according to a condition or over a sequence of values.
- How it is used
- Iterate over collections, maps, ranges, and condition-controlled work in Kotlin programs.
- How deep it goes
- Explains loop forms through ranges, map destructuring, indexing, and nested-loop labels; defers destructuring details.
- Examples
- Demonstrates color collections, binary character maps, indexed lists, Fizz-Buzz, and reverse stepped counting.
- What you can do after
- Apply it via Kotlin loop syntax to traverse collections, maps, and numeric ranges without manual index updates.
Python Workout, Second Edition
A for loop is a control-flow construct that repeatedly executes a block while iterating over items in an iterable.
- How it is used
- Uses direct iteration to process each item, perform side effects, or support transformations across Python iterables.
- How deep it goes
- Descends from direct iteration and loop choice to iter, next, __iter__, __next__, and StopIteration, without covering broader control-flow syntax.
- Examples
- Demonstrates indexed alphabet output, number guessing, Pig Latin translation, file creation, and comma-joined numeric output.
- What you can do after
- Build it from scratch by iterating over sequences, unpacking enumerate results, selecting comprehensions, and implementing repeated-input exercises.
Statistics Slam Dunk
A for loop is a control-flow construct that executes a block of code once for each value in a finite sequence or iterable.
- How it is used
- Automates repeatable R tasks such as generating multiple NBA Lorenz curves.
- How deep it goes
- Defines loop syntax, explains index replacement, and demonstrates a multi-plot workflow without covering advanced loop patterns.
- Examples
- Demonstrates multiplication across 1:5 and Lorenz curves across four NBA seasons.
- What you can do after
- Apply it via R to replace repeated code with one maintainable operation.
Grokking Simplicity
An iteration construct that repeatedly executes a block while progressing through a sequence or range of values.
- How it is used
- Uses for loops as algorithmic stepping stones toward clearer functional code.
- How deep it goes
- Explains loop-to-tool refactoring through behavioral reconstruction and code clues, without examining loop internals.
- Examples
- Uses nested loops, array slicing, accumulation, and moving averages as refactoring examples.
- What you can do after
- Apply functional tools to replace existing for loops incrementally.
Learn SQL in a Month of Lunches
A SQL procedural loop repeatedly executes a block of statements while its control conditions permit.
- How it is used
- Processes cursor result sets row by row inside stored procedures.
- How deep it goes
- Explains declaration, opening, fetching, condition handling, exit, and cleanup, but does not compare complete loop alternatives.
- Examples
- Demonstrates order totals and annual author payments using named cursor loops.
- What you can do after
- Operate/configure MySQL cursor loops that fetch rows, calculate values, conditionally insert records, and terminate safely.
The Well-Grounded Rubyist, Fourth Edition
A loop is a control-flow construct that repeatedly executes a segment of code according to an unconditional, conditional, or collection-based rule.
- How it is used
- Repeats code indefinitely, under a condition, or once per collection value.
- How deep it goes
- Works through break, next, conditional test placement, and a loop reimplementation using yield.
- Examples
- Uses a counter, integer printing, Celsius-to-Fahrenheit conversion, and a loop-like method.
- What you can do after
- Build it from scratch with a method that repeatedly yields, and choose a Ruby loop form for a repetition task.
Read how The Well-Grounded Rubyist, Fourth Edition explains loop →
The Quick Python Book, Fourth Edition
A for loop is a control-flow construct that iterates over the items supplied by an iterable.
- How it is used
- Iterates over values from an iterable to process items, including list elements and lines of text.
- How deep it goes
- Defines item-by-item execution and explains `break`, `continue`, and optional `else`, without developing iterable internals.
- Examples
- Shows a divisible-by-seven list search, reciprocal calculations with early exit, and file-based word and character counts.
- What you can do after
- Practice/perform iteration over Python values while skipping items, stopping early, and avoiding unnecessary repeated work.
Read how The Quick Python Book, Fourth Edition explains loop →
Modern C
A for loop is a C iteration construct that repeatedly executes a statement while controlling initialization, continuation, and update expressions.
- How it is used
- Controls repeated execution, especially iteration over a defined domain.
- How deep it goes
- Defines syntax, evaluation order, scoping advice, variants, and termination, while deferring size-type details.
- Examples
- Uses bounded counting, countdowns, dynamic stopping bounds, infinite loops, and Heron approximation.
- What you can do after
- Build it from scratch by selecting initialization, condition, update, and body clauses for repeated C tasks.
Learn Rust in a Month of Lunches
A for loop is Rust iteration syntax that repeatedly executes a block for each item produced by an iterable value.
- How it is used
- Uses for loops to repeat an action over ranges, ignored values, and collection items.
- How deep it goes
- Explains syntax, inclusive and exclusive ranges, unused variables, and tuple patterns without descending into iteration internals.
- Examples
- Demonstrates numeric ranges, ignored values, unused-variable warnings, tuple destructuring, and vector indexing.
- What you can do after
- Apply via Rust syntax to repeat work over ranges or collection items and respond appropriately to compiler warnings.
Build an AI Agent (From Scratch)
A loop workflow repeatedly runs one or more agents across iterations until a stopping condition is met or an iteration limit is reached.
- How it is used
- Uses repeated agent execution to refine measurable outputs within a developer-defined workflow.
- How deep it goes
- Implements nested iteration, context propagation, a result-based stop condition, and an iteration cap.
- Examples
- Demonstrates scored writing review, keyword and length checks, and a write–review stage inside a larger pipeline.
- What you can do after
- Build it from scratch with ordered agents, a stop-condition callback, and a maximum iteration count.
100 C++ Mistakes and How to Avoid Them
A for loop is a C++ loop construct that places initialization, continuation testing, and iteration update in its control statement around a loop body.
- How it is used
- Uses compact initialization, continuation testing, updating, and body execution for repeated processing.
- How deep it goes
- Explains four loop sections and continue control flow, while stopping short of broader loop design.
- Examples
- Demonstrates divisibility testing, an infinite while loop, a corrected update, scoped loop variables, and a FOR macro.
- What you can do after
- Diagnose/debug with it: trace initialization, testing, body execution, updating, and continue paths to find nontermination.
Read how 100 C++ Mistakes and How to Avoid Them explains loop →
Fast Python: High performance techniques for large datasets
- How it is used
- Compares Python and pandas row-traversal strategies while calculating tip measures from taxi records.
- How deep it goes
- Benchmarks explicit loops, iterrows, itertuples, and apply, then recommends vectorization for repeated computations.
- Examples
- Calculates taxi tip-to-total measures using summed values and per-row fractions on sampled data.
- What you can do after
- Evaluate row-wise strategies against vectorization and recognize when implementations calculate different aggregates.
Read how Fast Python: High performance techniques for large datasets explains loop →
100 Go Mistakes and How to Avoid Them
A classic for loop is a Go loop construct controlled by initialization, condition, and post statements rather than a range clause.
- How it is used
- Uses explicit initialization, condition, and post statements to control iteration and mutate indexed data.
- How deep it goes
- Traces condition evaluation, slice growth, copied range values, and deferred cleanup, but stops short of implementation internals.
- Examples
- Uses growing-slice loops, account updates, channel-driven file processing, and per-iteration deferred file closure.
- What you can do after
- Diagnose nontermination, copied-value mutations, and resource leaks by tracing loop conditions, element access, and defer scope.
Read how 100 Go Mistakes and How to Avoid Them explains loop →
Rust in Action: Systems programming concepts and techniques
A for loop repeatedly executes a block while iterating over the elements of a sequence or iterator.
- How it is used
- Teaches readable iteration through collections, ranges, and iterators while highlighting ownership and borrowing choices.
- How deep it goes
- Explains syntax, ownership modes, references, ranges, indexing pitfalls, and compiler expansion, but defers detailed rationale to ownership treatment.
- Examples
- Uses collection traversal, fixed-count ranges, mutable element updates, and file hexdump processing as concrete examples.
- What you can do after
- Apply for loops to traverse collections, borrow or mutate elements, repeat fixed actions, and process buffered file data.
Read how Rust in Action: Systems programming concepts and techniques explains loop →
Go in Action, Second Edition
A for loop is a Go control-flow construct that repeatedly executes a block according to optional initialization and post clauses and a loop condition or range clause.
- How it is used
- Uses for loops to scan strings, traverse arrays, process streamed input, and accumulate results.
- How deep it goes
- Explains three-part execution, range value-copy behavior, indexed mutation, and Scanner termination, but defers broader loop forms.
- Examples
- Demonstrates character scanning, array traversal, reverse iteration, skipped elements, and line-by-line word counting.
- What you can do after
- Apply for loops to scan data, traverse collections, mutate indexed elements, and process Scanner input safely.
Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu
Iteration is the repeated processing of items in a collection or the repeated definition of infrastructure instances.
- How it is used
- Uses iteration to transform data, generate strings, and multiply or conditionally define Terraform resources.
- How deep it goes
- Explains resource, data, template, and dynamic-block iteration with examples, but defers detailed for-expression treatment.
- Examples
- Demonstrates template collection loops, repeated security-group ingress rules, and conditional HTTPS ingress generation.
- What you can do after
- Build dynamic Terraform configurations by transforming collections, multiplying resources, and toggling nested blocks.
Read how Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu explains loop →
Related concepts
- arrayuses · An array is an indexed, ordered collection of elements arranged in one or more dimensions, with elements accessed by position.
- comprehensionalternative to · A comprehension is a language construct that creates a collection by iterating over one or more sources, optionally filtering elements and transforming them.
- iteratoruses · An iterator is an object or abstraction that provides successive values from a sequence or data source through a traversal protocol.
- functionuses · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- cursorused by · A database cursor is an object or interface that executes database operations and incrementally retrieves or traverses their result rows.
- higher-order functionkind of · A higher-order function is a function that accepts functions as arguments, returns functions as results, or both.
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.


























