continue
` statement in a `while
` loop :# Using the continue statement in a while loop
count = 0
while count < 5:
count += 1
if count == 3:
continue
print("Count is", count)
print("Done.")
Count is 1
Count is 2
Count is 4
Count is 5
Done.
while
` loop to repeat a block of code as long as the value of `count
` is less than `5
`. Inside the loop, we increment the value of `count
` by `1
` using the `+=
` operator.if
` statement to check if the value of `count
` is equal to `3
`. If it is, we use the `continue
` statement to skip the rest of the code in the loop and go back to the beginning of the loop.count
` is not equal to `3
`, the program continues to execute the `print()
` statement, which prints the current value of `count
`.count
` reaches `5
`, the loop exits, and the program continues to execute the `print()
` statement outside the loop, which prints the message "Done
."continue
` statement to skip certain iterations of a loop based on a condition.