Although the for loop in Python is not the same as other languages, jumping out of a loop is like most languages, you can use the keyword continue to jump out of this loop or break out of the entire for loop.
Break
For x in range: if X==5:break print X
The break loop used above, so the entire for loop jumps out when it executes to x==5, so the print X statement terminates only when it hits 4, so the output
The continue code is as follows:
For x in range: if x==5:continue print X
Execution Result: 0
1
2
3
4
6
7
8
9
The above loop uses the continue to jump out of this cycle, so only in the x==5 when the time out of the loop, and then continue the next time, so the print x statement is not executed at the time of x==5, the other values are executed, the output
Problem:
For I in Rangge (Ten): if i = = 2:continue elif i = = 5:break Print I
Python jumps out of the loop statement the difference between continue and break