Python-Indentations
Wed 12 November 2025
# created : 20250112
# https://www.scientecheasy.com/2022/09/indentation-in-python.html/
# Python indentations
# in python indendation means the whitespace
# after function definition we have to give four indendation
def display():
var = "Scientech Easy"
print(var)
display()
Scientech Easy
def display(parameter):
var = "Hello"
print(var)
print(var, parameter)
display("Python")
Hello
Hello Python
name = 'Ivaan'
if name == 'Ivaan':
print('WelCome Ivaan..')
print('How are you, today?')
else:
print('Dude! whoever are you ')
print('Why are you here?')
WelCome Ivaan..
How are you, today?
print('I am fine, thank you!')
print('Have a nice day!')
I am fine, thank you!
Have a nice day!
def school(parameter):
print(parameter)
def city(parameter):
print(parameter)
school("carmel school")
carmel school
city("chennai")
chennai
# error code for indentation
if(6 > 3):
print("6 is greater than 3")
Cell In[29], line 2
print("6 is greater than 3")
^
IndentationError: expected an indented block after 'if' statement on line 1
if(6 > 3):
print("6 is greater than 3") # --> corrected code
6 is greater than 3
if(6 > 3):
print("6 is greater than 3")
6 is greater than 3
a = 10
b = 20
c = 30
if(b > a):
print("b is greater than a")
print("b is greater than a but less than c") # --> mismatch indentation
Cell In[1], line 6
print("b is greater than a but less than c")
^
IndentationError: unexpected indent
a = 10
b = 20
c = 30
if(b > a):
print("b is greater than a")
print("b is greater than a but less than c")
b is greater than a
b is greater than a but less than c
def display(parameter):
institute = "Scientech Easy"
print(institute) # mismatch indentation
print(parameter)
display('Dhanbad')
File <tokenize>:3
print(institute) # mismatch indentation
^
IndentationError: unindent does not match any outer indentation level
def display(parameter):
institute = "Scientech Easy"
print(institute)
print(parameter)
display('Dhanbad')
Scientech Easy
Dhanbad
Score: 25
Category: python-basics