Python Syntax
Python syntax is clean, readable, and easy to understand.
Execute Python Syntax
Python syntax can be executed by writing directly in the command line, or by creating a .py file. On this site, you can run it live with the ▶ Try it button.
Indentation
Indentation refers to the spaces at the beginning of a code line. In Python, indentation is required — it indicates a block of code. Other languages often use curly-braces for this.
IndentationError if you skip the indentation. The number of spaces is up to you, but it must be consistent within the same block. 4 spaces is the standard.
Python Variables
Python has no command for declaring a variable. It is created the moment you first assign a value to it:
Comments
Python has commenting capability for in-code documentation. Comments start with a #:
Multi Line Statements
Python normally uses one line per statement. You can use a backslash \ to extend to the next line: