Unexpected indent error occurs when there is some misalignment in the code. This could be due to whitespaces used in Python, as Python is a structured programming language and follows proper indentations.
For Example: using in a for loop
animals = ['cat','dog','rat']
for item in animals:
print(item)
IndentationError: expected an indented block
The correct way is:
animals = ['cat','dog','rat']
for item in animals:
print(item)
Output
cat
dog
rat
Here, in the above example four whitespaces are required and if not followed correctly then there is an indented block error.
Thus, if proper spacing and correct whitespaces are not used there ae chances to get this error in python.
Hope this was helpful.