IndentationError: unindent does not match any outer indentation level

Yawin Tutor
1 min readApr 6, 2021

The IndentationError: unindent does not match any outer indentation level error occurs when you use both spaces and tabs to indent in your code. You can define a code block with any amount of indent, but the indent must match exactly to be at the same level. The IndentationError: unindent does not match any outer indentation level error indicates that there is an excess indent in the line that the python interpreter does not expect to have. The unindent code does not match with any outer indentation. To fix the issue, make sure the code contains either spaces or tabs.

In python, the error IndentationError: unindent does not match any outer indentation level occurs when you add excess indents at the beginning of the line. The compound statement and functions requires the indent to be distinguished from other lines. If the indent does not match with any of the outer indentation level, the error will be thrown.

The indent is defined as the distance or number of empty spaces between the start of the line and the left margin of the line. Indents are not considered in the most recent programming languages such as java, c++, dot net, etc. Python uses the indent to distinguish compound statements and user defined functions from other ..more…

Root Cause of the error

Exception stack trace

How to fix this error

--

--