Indentation
Indentation refers to the spaces at the beginning of a code line.
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.
Python will give you an error if you skip the indentation.
There are no curly brackets - indentation is used instead
Indentation is required in Python. A Python interpreter can be informed that a group of statements belongs to a specific block of code by using Python indentation.
Indentations make the code easy to read for developers in all programming languages but in Python, it is very important to indent the code in a specific order.
Indentation - every indented block is indented by 4 spaces
def adjust_price(price: float, age: int) -> float:
if age > 60:
return price * .8
else:
return price
assert_equal(adjust_price(5.75, 63), 4.60)
assert_equal(adjust_price(5.75, 45), 5.75)
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext