break, return, and Empty Statements

Python Java
The break statement exits a loop.

while True:
    break

The return statement exits a function or method.  If no expression is specified, the value None is returned.

return 0

The pass statement does nothing.

while True:
    pass

String literals are formed using the double quotes as delimiters.

The break statement exits a loop.

while (true)
    break;

The return statement exits a method.  If no expression is specified, the value void is returned.  The value returned must be type compatible with the method’s return type.

return 0;

The empty statement is an extra semicolon and does nothing.

while (true)
    ;

© Ken Lambert. All rights reserved.