{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "concept",
  "slug": "concepts/loops",
  "name": "Loops",
  "section": "CS Concepts",
  "canonical_definition": "A loop is a control flow construct that causes a sequence of statements to execute repeatedly, either for a fixed number of iterations (for loop), while a condition holds true (while loop), or over each element of a collection (for-each / range-based loop), with the ability to exit early (break) or skip to the next iteration (continue).",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "source_count": 4,
  "url": "https://thecodex.expert/coding/concepts/loops/",
  "concept_relationship": {
    "requires_first": [
      "concepts/control-flow",
      "concepts/variables"
    ],
    "enables": [
      "concepts/arrays",
      "concepts/recursion",
      "algorithms/complexity"
    ],
    "commonly_confused_with": [
      "for-each != index loop; break only exits innermost loop; infinite loop != error"
    ]
  },
  "sources": [
    {
      "num": 1,
      "citation": "Knuth TAOCP Vol.1 1997",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "Dijkstra Discipline of Programming 1976",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "Python Language Reference \u00a78",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "ISO C17 \u00a76.8.5",
      "tier": 1
    }
  ]
}