The continue of Python continues to circulate
During the loop, you can use break to exit the current loop, and you can use continue to skip the subsequent loop code and continue the next loop.
Let's say we've written the code that calculates the average score using the For loop:
L = [98, M, M, ba, 85]sum = 0.0n = 0 inL: sum = sum + x n = n + 1print sum/n
Now the teacher just want to count the average of passing scores, it is necessary to cut off the score of x < 60, then, using continue, can be done when x < 60, do not continue to execute the loop body follow-up code, directly into the next cycle:
For x in L: if x <: continue sum = sum + x
Python's multiple loops
Inside the loop, you can also nest loops, let's look at an example:
In [' A ', ' B ', ' C ']: in [' 1 ', ' 2 ', ' 3 ']: print x + y
X cycles once,y loops 3 times, so we can print out a full array:
A1
A2
A3
B1
B2
B3
C1
C2
C3
n = n + 1
The continue of Python continues to circulate