continue
` statement in a `for
` loop :# Using the continue statement in a for loop
numbers = [1, 2, 3, 4, 5]
for number in numbers:
if number == 3:
continue
print(number)
print("Done.")
1
2
4
5
Done.
for
` loop to iterate over a list of numbers. Inside the loop, we use an `if
` statement to check if the current number is equal to `3
`. If it is, we use the `continue
` statement to skip the rest of the loop body and move on to the next iteration.print()
` statement outside the loop, which prints the message "Done
."continue
` statement to skip over specific iterations of a loop based on a condition. In this example, we skip printing the number `3
` and continue with the rest of the loop body.