Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Python Break


break statement is a jump statement that is used to pass the control to the end of the loop.

When break statement is applied the control points to the line following the body of the loop , hence applying break statement makes the loop to terminate and controls goes to next line pointing after loop body.

breakstatement

eg:

  1. for i in [1,2,3,4,5]:
  2.     if i==4:
  3.         print “Element found”
  4.         break
  5.     print i,

Output:

  1. >>>
  2. 1 2 3 Element found
  3. >>>

Flow chart of break:

Comments

comments