continue — Easy Examples
Skips the rest of the current loop iteration and moves to the next
Skip an iteration
Using continue to skip certain items in a loop.
python
# Print only odd numbers for i in range(10): if i % 2 == 0: continue print(i, end=" ") print() # Skip blank lines lines = ["hello", "", "world", "", "python"] for line in lines: if not line: continue print(line)
Expected Output
1 3 5 7 9 hello world python
continue skips the rest of the current iteration and jumps to the next one. The loop itself keeps running.
Want to try these examples interactively?
Open Easy Playground