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 the external condition is triggered requiring a speedy exit from a ring. The fracture statement can be utilized together while and for loops.

If you are adopting nested circles, the smash statement discontinues the implementation of the inmost loop and creates executing the subsequent line of the system after the block.


The syntax for a smashing statement in Python is as pursues:


Flow Diagram



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
Good bye!

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.