MWZ

MINDWAREZONE

Continue in python

  • The continue statement skips the current iteration of a loop.
  • It does not stop the loop; the loop continues with the next iteration.
  • It can be used inside both for and while loops.

Example 1: Continue in a for Loop

for num in range(1, 6): 
    if num == 3: 
        continue 
    print(num)
            

Output

1
2
4
5
            

Example 2: Continue in a while Loop

count = 0 

while count < 5: 
    count += 1 
    if count == 3: 
        continue 
    print(count)
            

Output

1
2
4
5