When you use a repeat block to loop your code,
how does the computer know when it's repeated
enough times? The repeat block is actually
hiding a more sophisticated piece of code
called a for loop which counts from a starting
value up to an ending value by a specific
increment. For example, a repeat three block
counts from 1 to 3 by 1. Every time it counts,
it runs the code inside the loop. The for
loop knows how many times it has run by using
a counter variable which is set to the starting
value at the beginning of the loop and has
the increment added to it each time the loop
is run. As soon as the counter variable is
greater than the ending value, the loop stops
running. The benefit of using a real for loop
instead of the repeat block is that you can
actually see the counter variable and use
it in your loop. For example, if I have a
series of flowers and the first one has one
nectar, the second one has two nectars and
the third one has three, I can use the for
loop to tell the bee to collect 'counter'
nectars each time, which would one at the
first flower, two at the second and three
at the third. Also in a for loop, you can
increment the counter by a number other than
one each time. You can potentially count by
2s, 4s or even an amount that changes every
time through.