Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Loops
Repeat until
1repeat until the jug is full2 scoop a cup3 pour it in4 look at the jug
Repeat until checks every time round.
The big ideaA repeat until loop keeps going until something becomes true. It checks each time round.

How it works

A repeat until loop keeps going until something becomes true.

It checks each time round, so you do not need to know the number.

A counting loop needs you to know the number. Repeat until works when you do not.

The same repeat until program works for a small jug and a huge barrel.

Counting loop• repeat 10 times• stops at ten• you must know the numberRepeat until• repeat until full• stops when the check says yes• works for any size
Two ways to stop a loop.

Example 1: Counting too far

  1. Mina's first program says repeat 10 times: scoop a cup, pour it in.
  2. The jug holds only 6 cups.
  3. Cup 7 spills water across the table, because Bo never looks.

Example 2: Repeat until

  1. Mina changes it to repeat until the jug is full.
  2. Bo scoops, pours and looks, again and again.
  3. At cup 6 he looks, nods and stops, and not one drop spills.
1repeat until the jug is full2 scoop a cup3 pour it in4 look at the jug
Line 4 is the check.

Example 3: A bigger barrel

  1. Teo rolls in a barrel that takes 15 cups.
  2. The same program, repeat until the barrel is full, still works.
  3. It needs no new number.

Example 4: The toy train

  1. Teo's train program says repeat 5 times, move one piece of track, but the track is 8 pieces long.
  2. The train stops after 5 pieces, so 8 - 5 = 3 pieces are left, and it stops before the station.
  3. The fix: repeat until at the station, which checks each time.

Words to know

repeat until
A loop that keeps going until something becomes true.
check
Looking to see if the answer is yes yet.
counting loop
A loop that repeats a set number of times.

Watch out

Try it

  1. Is stirring paint until it is smooth a counting loop or a repeat until?
  2. Is clapping 5 times a counting loop or a repeat until?
  3. When does a repeat until loop check?
  4. A track is 12 pieces and the train moves 5. How many pieces are left?
  5. Which works for any size of jug: repeat 6 times or repeat until the jug is full?
Answers: 1. A repeat until · 2. A counting loop · 3. Every time round · 4. 7 · 5. Repeat until the jug is full
Try at homeStir something with a grown-up, like pancake batter or paint, until it is smooth. Did you count your stirs? No, you looked, and that is repeat until. Find two more things you do until something happens, like walking until you reach the door.
For grown-upsDo the Mission: stir something together, like pancake batter or paint, until it is smooth. Did you count your stirs? No, you looked. Find two more things you do until something happens, like walking until you reach the door.
Open these notes on screenScan the code, or go to tutorpip.com.