Lesson 6
Dealing with Sequences of Objects
Chapter 4: for loops
continue
If you noticed, I used break
in one of the questions earlier to break out of a for
loop. Hopefully you are familiar with break
by now!
Here is another statement that can be used to alter the flow of a loop. It is called continue
. It immediately jumps to the beginning of the loop without executing the remaining statements in the loop.
Just imagine your favourite panel on an audition interrupting you saying “Thank you! Next!” when he/she has seen or heard enough! That’s the main idea behind continue
.
You can use continue
with while
and for
loops, but it makes more natural sense with for
loops.