[Solved] Why is Python strict about indentation? [closed]


Indentation is essential in Python; it replaces curly braces, semi-colons, etc. in C-like syntax.

Consider this code snippet, for example:

def f(x):
    if x == 0:
        print("x is zero")
        print("where am i?")

If it weren’t for indentation, we would have no way of indicating what code block the second print statement belongs to. Is it under the if statement, the function f or just by itself in the document?

0

solved Why is Python strict about indentation? [closed]