Glossary
Continue
Use of continue in Python loops
Python continue
is a keyword that will tell your code to move to the next item in a loop. It will skip all other code that comes after your continue
statement. This is heavily used with for
and while
loops in python.
Letβs talk about the example above. Imagine that youβre looping through the range(10) and you want to print each number except for 3. You can have a conditional statement to look for the number 3. If you find it, then tell python to continue on to the next item in your list.
Keep in mind that if you have nested loops, continue will only skip the item within the first loop it is placed in.
Letβs take a look at a python continue code sample.