20
loading...
This website collects cookies to deliver better user experience
# Bad indentation inside a function
def getMessage():
message= "Hello World"
print(message)
getMessage()
# Output
File "c:\Projects\Tryouts\listindexerror.py", line 2
message= "Hello World"
^
IndentationError: expected an indented block
# Proper indentation inside a function
def getMessage():
message= "Hello World"
print(message)
getMessage()
# Output
Hello World
# Bad indentation inside if statement
def getMessage():
foo = 7
if foo > 5:
print ("Hello world")
getMessage()
# Output
File "c:\Projects\Tryouts\listindexerror.py", line 4
print ("Hello world")
^
IndentationError: expected an indented block
# Proper indentation inside if statement
def getMessage():
foo = 7
if foo > 5:
print ("Hello world")
getMessage()
# Output
Hello world