The Python language uses strict "indentation" to indicate the format framework of the program. Indentation refers to the blank space before the beginning of each line of code, which is used to indicate the inclusion and hierarchical relationship between codes.
1 indent = 4 spaces.
Indentation is the only way to indicate the program framework in the Python language. When expressing program meanings such as branches, loops, functions, classes, etc., complete statements containing reserved words such as if, while, for, def, class, etc. Finally, it ends with an English colon (:) and is indented afterwards, indicating the ownership relationship between the subsequent code and the immediately unindented statement.
Indentation style
Single-level indentation:
Multiple-level indentation:
For more Python related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of What does the Python language use to distinguish code levels?. For more information, please follow other related articles on the PHP Chinese website!