## What does error mean Expected an indented block in Python?

Last Updated On Sunday 16th Jan 2022

## expected an indented block

Python’s use of indentation makes code very easy to read.Basically, it uses whitespace to force you to write neatly formatted code with a clear visual structure.

	def value(one,two):
if one < two:
return two
else:
return one




Python doesn’t have curly braces , so it must somehow know where the block starts and ends, indented here.

For each code, if it is inside another (function, loop, if statement, etc.), It must be indented by 4 spaces (or a key tab).

If You try to run the above following code , it throws the below error

	IndentationError: expected an indented block



## expected an indented block python

if it is inside another (function, loop, if statement, etc.), It must be indented by 4 spaces (or a key tab), no more and no less .

	def value(one,two):
if one < two:
return two
else:
return one



Always remember to indent, this is the essence of Python!

### Forgetting to Indent Additional Lines

Sometimes your loop will run without any errors but won’t produce the
expected result. This can happen when you’re trying to do several tasks in a loop and you forget to indent some of its lines.

### Indenting Unnecessarily

If you accidentally indent a line that doesn’t need to be indented, Python informs you about the unexpected indent.

	mess = "Hello World"
print(mess)



We don’t need to indent the print() call, because it isn’t part of a
loop. Hence, Python reports that error.

	  print(mess)
^
IndentationError: unexpected indent