> For the complete documentation index, see [llms.txt](https://cs.brash.ca/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cs.brash.ca/unit-3/loops.md).

# Loops (Repeating Code)

Another method of control is **repetition**. You wouldn't want to write all of the code that does something one hundred times. That would be like writing the same sentence one hundred times. For that, we ask the computer to do something repeatedly. We will look at *count-controlled* `for` loops and c*ondition-controlled* `while` or `do`  loops.

[**Khan Academy**](https://www.khanacademy.org/computing/computer-programming/programming#looping) employs something I really like\
&#x20;       **The Three Loop Questions**\
&#x20;       `1. What do I want to repeat?`\
`2. What do I want to change each time?`\
`3. How long should it repeat?`\
\
Select one of the following to learn more about the different types of loops (syntax listed below for quick reference).

{% content-ref url="/pages/-LOpFBpv3exQtYLUgHZx" %}
[For...Loop](/unit-3/loops/for-loop.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LKgJPC1rJ7f-IEQJMU6" %}
[While & Do/While Loops](/unit-3/loops/while-loop.md)
{% endcontent-ref %}

{% tabs %}
{% tab title="For Loop Syntax" %}
![Image by Author](/files/-LPm8HWLVOdtIUBDwh1v)
{% endtab %}

{% tab title="While Loop Syntax" %}
![Image by Author](/files/-LQKfqubMoK2K5tC9HWH)
{% endtab %}

{% tab title="Do While Syntax" %}
![Image by Author](/files/-LQKfxXCK3iMCbkysFS5)
{% endtab %}
{% endtabs %}
