3 Antworten
+ 6
continue is basically used to skip code in a while loop and rerun the loop if some condition is met. For example:
num = 1
while num < 10:
if num % 2 == 0: #if num is even
print(num)
continue #we skip over the code that adds one to 10, essentially meaning this loop will continue running over and over again at 2
num += 1
In this example, if the variable num is an even number, we skip the code that adds one to num. This means the while loop will run forever.
+ 5
Use to jump directly to the next iteration in the loop.
0
In simple words, 'continue' just skip the code below and start the loops again. Use for run the loops again and skip the code below if certain cond occurred.