Continue statement is used when you want to skip the loop for a certain condition and continue iterating with the next item on the list. Continue doesn’t break the loop like the break statement does, instead it skips current iterating element and continues with the next item on the iteration.

Continue statement must be used inside a loop block and it is generally used after an if conditional statement.


Using Continue Statement In Python

Here is a sample code snippet demonstrating usage of continue statement in Python:

for fruit in ["apple", "banana", "kiwi", "strawberry"]:

   if fruit == "banana":
      continue    # skip this item

   print('I <3 ' + fruit)

print('The end.')

This sample code snippet outputs the following:

I <3 apple
I <3 kiwi
I <3 strawberry
The end.