0% completed
The continue
statement in Python is used to skip the current iteration of a loop and move to the next one. Unlike break
, which completely stops the loop, continue
allows the loop to keep running while skipping specific iterations based on a condition.
for variable in sequence: if condition: continue # Skips the rest of the loop body for this iteration # Other statements inside the loop while condition: if condition: continue # Skips the rest of the loop body for this iteration # Other statements inside the loop
continue
works in both for
and while
loops.continue
, it jumps back to the start of the loop, skipping any code below it in the current iteration.1
to 5
.num
is 3
, the if
condition is True
, so continue
skips printing 3 and moves to the next iteration.1
to 10
, increasing count
in each iteration.count
is even, continue
skips printing that number.The continue
statement is used to skip specific iterations of a loop without stopping the entire loop. It allows the program to ignore certain conditions while still executing the rest of the loop.
.....
.....
.....