In python IndentationError: expected an indented block after function definition on line we face this error message when we create a def function and do incorrect indentation then the python interpreter shows this error message, If you want to fix this error you need to just add 4 spaces or just use tab key one time, For more clarification see the below example.
Wrong Code
def welcome(name):
return "Welcome, " + name + "!"
user_name = input("What is your name? ")
print(welcome(user_name))
#use return inside def with correct indented block return welcome(user_name)
Error Massage
File "/home/kali/python/webproject/error/main.py", line 2
return "Welcome, " + name + "!"
^
IndentationError: expected an indented block after function definition on line 1
Wrong code line
def welcome(name):
return "Welcome, " + name + "!"
Correct code line
def welcome(name):
return "Welcome, " + name + "!"
- Wrong action: incorrect indentation.
- Correct action: Just add 4 spaces.
Entire Correct Code line
def welcome(name):
return "Welcome, " + name + "!"
user_name = input("What is your name? ")
print(welcome(user_name))
#use return inside def with correct indented block return welcome(user_name)
What is IndentationError: expected an indented block after function definition on line?
In python we face this error message when we create a def function and do an incorrect indentation then the python interpreter shows this error message.
How to fix IndentationError: expected an indented block after function definition on line?
If you want to fix this error you need to just add 4 spaces or just use tab key one time, For more clarification see the above example.
For more information Visit YouTube Channel.

