Repeat Until

Repeat Until

There is another Scratch piece that lets us repeat things. It is called repeat until.

  • Just like repeat, it will do everything inside the C-shaped block a number of times.
  • Just like if, it is dependent upon a condition. Before it starts the loop each time, it checks to see if the condition (below, x > 5) is true. If this is condition is true, then it will not repeat again.

The repeat until block can be really helpful to keep track of what the variable x is at each point to help us understand how this new piece works.

  • In the right column we keep track of the value of x.
  • In the diagram below we draw a horizontal line every time we start the loop.
    • Here we labeled each line “Top of loop” and “Bottom of loop,” but we could just use the horizontal line to keep track of this information.
  • Within each loop the variable x increases by 1, so we write down the new value for x.

Try It Out!

Use a chart like the one above to keep track of what would happen in the complicated repeat until code below. Try it without Scratch!