Python Break Statement
It finishes the present loop and recommences implementation at the next declaration, just like the customary break statement in C.
The mainly common utilize for fracture is when a number of external condition is triggered requiring a speedy exit from a ring. The fracture statement can be utilized in together while and for loops.
If you are adopting nested circles, the smash statement discontinues the implementation of the inmost loop and create executing the subsequently line of system after the block.
The syntax for a smash statement in Python is as pursues:
for letter in 'Python': # First Example
if letter == 'h':
print 'Current Letter :', letter
var = 10 # Second Example
while var > 0:
print 'Current variable value :', var
var = var -1
if var == 5:
print "Good bye!"
When the above code is executed, it produces the following result:
Current Letter : P
Current Letter : y
Current Letter : t
Current variable value : 10
Current variable value : 9
Current variable value : 8
Current variable value : 7
Current variable value : 6
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.