Code Indentation

Whitespace is significant

In Python whitespace is significant. Block starts with significant white space, The block ends when the indentation becomes smaller (less).

print("Code Indentation Demo")
if True:
    print("Begin of Block")
print("Not part of if block") # Less indentation , not a part of block

Even below code style is correct but not recommended. Having four spaces is preferable

print("Code Indentation Demo")
if True:
 print("Begin of Block")
print("Not part of if block") # Less indentation , not a part of block

Significant Whitespace Rules

PEP 8(Python Enhancement Proposals)

PEP 8 - Style Guide for Python Code.

Python Home