Language Syntax

Blank lines — Python syntax

Blank or comment-only logical lines in a file do not produce a statement NEWLINE token and do not close an indented suite. In the standard interactive interpreter an entirely blank line can terminate a compound input.

Formal Syntax & Structure

python syntaxpython
blank line: no non-whitespace characters, or only a comment

Working Example

Example Snippetpython
source='if True:\n    x=1\n\n    # note\n    y=2\n'ns={}exec(source,ns)print((ns['x'],ns['y']))
Python Reference