Knowledge Base‎ > ‎Programming‎ > ‎Python‎ > ‎Python Reference‎ > ‎

break


Related:

 Examples

 
 
n = 0
while True:
  n = n + 1
  if n > 10:
    break

 Description        

 
Ends the current while or for loop.

 Syntax

 
 
break

 Parameters

 

 Interpreter

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> n = 0

>>> while True:

...   n = n + 1

...   if n > 10:

...     break

...

>>> n

11




Comments