ReferenceKeywords
break
Leaves the innermost loop immediately.
Signature
breakReturns
Nothing.
Example
Python
for n in [1, 2, 3, 4]:
if n == 3:
break
print(n)Output
1 2
Basics
Strings
Collections
Functions
Classes and objects
Modules and the standard library
Files and errors
Beyond the basics
ReferenceKeywords
Leaves the innermost loop immediately.
breakNothing.
for n in [1, 2, 3, 4]:
if n == 3:
break
print(n)Output
1 2