Lesson 7 of 10

Again and again

A loop does the same job again and again.

Scene 1 of 5

Three lines to say Hi three times. That is a lot of typing!

  1. Hi!
  2. Hi!
  3. Hi!
Scene 1 of 5

Tip

Write it once, and the loop repeats it for you.

Library

All about loops

What is a loop?

A loop does the same job many times. You write the job only once.

Counting with i

The loop keeps a counter called i. Each time around, i gets one bigger.

When does it stop?

The loop checks a rule before every turn. i < 3 means keep going while i is less than 3.

Say it again
Hi! Hi! Hi!
Count
1, 2, 3

Words to know

  • loop = do it again
  • i = the counter
  • ++ = add one