Full parsing of break, continue, exit () and pass in python, and full parsing in python
1. break
Break terminates this loop. For example, if you write a break in one of the while loops that meet the condition, only the loop in the while loop is terminated, the program will jump to the previous layer while the loop continues to go down
Take a simple for loop as an Example
For I in range (10): print ("----- % d -----" % I) for j in range (10): if j> 5: break print (j)
When j> 5 is encountered, the for on the second layer will not be cyclic, And the next layer will continue to be cyclic.
2. continue
When the continue is directed to this point, execute some operations in the continue. After the execution is complete, continue the loop that meets the conditions, and do not terminate the loop.
The above example is modified.
For I in range (10): print ("----- % d -----" % I) for j in range (10): if j> 5 and j <= 8: print ("I am a special continue") continue print (j)
Here, the loop will print out the things that j needs to do between 5 and 8, but it will not terminate the second-layer loop. If it does not meet the number between 5 and 8, it will then loop the things that need to be done below.
3. exit ()Exit the entire program.
4. passIt's just a placeholder and does nothing.
The full analysis of break, continue, exit (), and pass in python above is all the content that I have shared with you. I hope to give you a reference and support for the customer's house.