The continue statement is used in a while or for loop to take the control to the top of the loop without executing the rest statements inside the loop. Here is a simple example.
for x in range(7):
if (x == 3 or x==6):
continue
print(x)
Output:
0 1 2 4 5
In the above example, the for loop prints all the numbers from 0 to 6 except 3 and 6 as the continue statement returns the control of the loop to the top
Comments
Post a Comment