Summary of Three Methods of Python Loop Termination Statement
- 2021-07-01 07:43:54
- OfStack
In Python, there are three kinds of loop termination statements:
1. break
break is used to exit this layer loop
Examples are as follows:
while True:
print "123"
break
print "456"
2. continue
continue is to exit this cycle and continue the next cycle
Examples are as follows:
while True:
print "123"
continue
print "456"
3. Custom tag Tag
Self-defined 1 marked True or False
Sample code:
Tag = True
while True:
print "123"
print "456"
Tag = False