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
PEP 8 - Style Guide for Python Code.