Show how the same lines of code produce different results purely because of how they are indented, and explain the scope that indentation creates.
Indentation is not decoration in Python. It is the block syntax. The parser uses the spaces at the start of a line to decide which statements belong to the same body, so two programs that contain exactly the same words can behave differently because of nothing but the whitespace.
def collect(flag):
result = []
if flag:
result.append('a')
result.append('b')
result.append('c')
return result
print(collect(True)) # ['a', 'b', 'c']
print(collect(False)) # ['c']
Both of the append calls sit inside the body of the if, because they are indented one level deeper than the if itself. The last append is at the same level as the if, so it always runs. Move it out by four spaces and the meaning of the block changes completely.
Indentation also decides the scope, and that is why a name that you create inside a block disappears when the block ends.
def scope_demo():
inner = 'visible here'
if True:
deeper = 'also visible here'
return inner
print(scope_demo())
print(deeper) # NameError: name 'deeper' is not defined
Every function, loop, conditional, with block, and try block creates its own local scope. Names that you bind inside it are visible only inside it, and they are gone once the block finishes.
The practical result for code review is that indentation carries real meaning. One stray space can change what a program does without giving you an error, and that is exactly why mixing tabs and spaces is dangerous. The same file can look identical in two editors and still be read in two different ways.