CKTIS / Python
Keyword continue
Skip the rest of the current iteration in the nearest loop.
Version: Python 3.14; repository image, production runtime not attested
Syntax
while condition:
if skip():
continueSkip the rest of the current iteration in the nearest loop.
A for loop requests the next item, while a while loop retests its condition. A finally suite crossed by continue still executes.
Unlike break, continue does not suppress a loop else when the loop later finishes normally.
Examples
trace = []
for n in range(3):
try:
if n == 1:
continue
trace.append(n)
finally:
trace.append(f"end{n}")
else:
trace.append("done")
print(trace)
Result
[0, 'end0', 'end1', 2, 'end2', 'done']
Unlike break, continue does not suppress a loop else when the loop later finishes normally.