File "demo_indentation_test.py", line 2 print("Five is greater than two!") ^ IndentationError: expected an indented block 1

File “demo_indentation_test.py”, line 2 print(“Five is greater than two!”) ^ IndentationError: expected an indented block

f 5 > 2:
print("Five is greater than two!")

ERROR : File "demo_indentation_test.py", line 2
    print("Five is greater than two!")
        ^
IndentationError: expected an indented block
_____________________________________________________________________________
f 5 > 2:
    print("Five is greater than two!")
    
ERROR : No Error !

Here is what the above code is Doing:
1. The first line is a comment.
2. The second line is a condition.
3. The third line is a code block.

The code block is only executed if the condition is true.

The code block is defined by how much the code is indented.

In Python, indentation is very important.

The amount of indentation is up to you, but it must be consistent throughout that block.

Notice that the lines print(“Something is going on here.”) and print(“The condition is true”) are not indented.

This means that they are not part of the code block.

The code block starts at the line print(“Five is greater than two!”)

The code block ends when the indentation is reduced.

The code block can contain many statements.

The condition can be any expression, and true is any non-zero value.

The indented statements are executed if the condition is true.

If the condition is false, the indented statements are skipped.

_____________________________________________________________________________

Similar Posts