Iteration

Also known as: loop, repetition

structure

Repeating a block of instructions multiple times until a stopping condition is satisfied. Powers processing of lists, searching, and any repeated action.

💡 Intuition

Do this again and again until some condition is met, then move on to the next step.

Core Idea

Loops let you do repetitive tasks without writing repetitive code.

🔬 Example

Stir soup until it boils. Print numbers 1 to 100 using a loop instead of 100 print lines.

🎯 Why It Matters

Powers processing of lists, searching, and any repeated action.

⚠️ Common Confusion

The loop must have a way to stop—every iteration should progress toward the stopping condition.

Related Concepts

Prerequisites

How Iteration Connects to Other Ideas

To understand iteration, you should first be comfortable with sequence. Once you have a solid grasp of iteration, you can move on to while loop, for loop and recursion.

Learn More

Common Mistakes Guides

Go Deeper

Frequently Asked Questions

What is Iteration in CS Thinking?

Repeating a block of instructions multiple times until a stopping condition is satisfied.

Why is Iteration important?

Powers processing of lists, searching, and any repeated action.

What do students usually get wrong about Iteration?

The loop must have a way to stop—every iteration should progress toward the stopping condition.

What should I learn before Iteration?

Before studying Iteration, you should understand: sequence.

💻 Animated Visualization Animated

Watch the loop counter increment