Python continue Keyword

Example

If the variable i is 5, skip the iteration but continue to the next iteration:

for i in range(9):
  if i == 5:
    continue
  print(i)

Run Instance

Definition and Usage

The continue keyword is used to end the current iteration in a for loop (or while loop) and then continue to the next iteration.

More Examples

Example

Using the continue keyword in while loop:

i = 0
while i < 9:
  i += 1
  if i == 5:
    continue
  print(i)

Run Instance

Related Pages

Usage break Keyword Completely end the loop.

Please visit our Python For Loop Tutorial Learn more about loops in Chinese.

Please visit our Python While Loop Tutorial Learn more about loops in Chinese.