🧩 Block coding, Grade 5 · session 3 of 14 · 60 minutes · 🎁 free with an account

Repeat until: loops that know when to stop

Sometimes you do not know how many times to repeat. Repeat until keeps going until something happens, like Byte reaching the star. The loop checks before each round.

A complete lesson · 60 minutes

Teach it, see it, practise it, all on this page.

Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.

  1. Warm-up4 min
  2. Repeat until7 min
  3. Patterns inside7 min
  4. Which loop?7 min
  5. code.org practical: puzzles 10–1318 min
  6. Activity 14 min
  7. Activity 24 min
  8. Activity 33 min
  9. Quiz5 min
  10. Set the project1 min

By the end you can

  • Explain the difference between repeat n times and repeat until
  • Use repeat until to reach a goal
  • Predict how many moves a repeat until loop makes

Before you start

  • Loops: repeat (session 2)

Have ready

  • code.org open in another tab
  • A ball or a soft toy

Grade 5 · ages 9 to 11 · beginner

Warm-up · think first

Keep clapping until I say stop!

Show the answer

You did not know how many claps; you kept going until something happened. That is repeat until.

Teacher tip: Play it twice with a different stopping point; ask how many claps they did.

More warm-ups for every class →

Part 1 of 3 · learn, see, practise

Repeat until: stop when it happens

repeat until ⭐ runs the blocks inside again and again until Byte is on the star.

You do not need to count the squares: the loop stops by itself.

Real-life loops: keep walking until you reach the door; keep stirring until the sugar melts.

Example 1

Byte does not know how far the star is. Which loop helps?

when runrepeat until ⭐move forward
  1. The path is straight, but long.
  2. repeat until ⭐ with move forward inside.
  3. Byte moves until it lands on the star, then stops.

Answer: repeat until ⭐: move forward

Practise it

Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.

Warm-up

Warm-up

Core

Stretch 🔥

Answers (for the teacher)
  1. 6
  2. repeat until
  3. until they are clean
  4. 7

🎁 Free for a year

Make a free account to open the rest of this lesson

Every new account opens every lesson of every course free for a whole year: no payment, no card, nothing to cancel.

Unlocking the rest of this lesson gives you:

  • Part 2: Patterns inside repeat until, with practice at three levels
  • Part 3: When to use which loop, with practice at three levels
  • Class activity 1: Walk until
  • Class activity 2: Repeat or until?
  • Class activity 3: Count the moves
  • A 8-question quiz
  • After-class project: Until-stories
  • Homework and a printable practice sheet with answers
  • Teach mode and the minute-by-minute teacher's plan

It takes a minute. Anyone under 13 signs up with a parent. The first 2 lessons of every course, every game and all maths practice stay free.

FAQ

Repeat until: loops that know when to stop: questions

What is a repeat until loop?

A loop that keeps running its blocks until something becomes true, such as reaching the goal; it does not need a number.

What is an infinite loop?

A loop whose stopping rule never comes true, so it never ends. Programmers avoid them.

Which code.org puzzles teach repeat until?

In the Classic Maze, repeat until appears around puzzle 10.

Start a conversation

Want a teacher to take this class?

Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.

  • Tell us the learner’s age or grade and goals
  • We’ll suggest a suitable class or learning path
  • We’ll confirm format, timing and fees with a parent or guardian

For a child’s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

We’ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try