close

[Solved] IndentationError: unindent does not match any outer indentation level

Hello Guys, How are you all? Hope You all Are Fine. I compile the Python code and I get IndentationError: unindent does not match any outer indentation level in Python. So Here I am Explain to you all the possible solutions here.

Without Wasting your time, Lets start This Article to Solve This Error.

How IndentationError: unindent does not match any outer indentation level Error Occurs ?

My Code is very simple but when I I compile my code I get below error.

IndentationError: unindent does not match any outer indentation level

Here is my code

    result = 1
    for i in range (1,100):
        result = result * i
    print "1 sum result is ",result

How To Solve IndentationError: unindent does not match any outer indentation level?

Question: How To Solve IndentationError: unindent does not match any outer indentation level?
Answer: To Solve IndentationError: unindent does not match any outer indentation level Just Try doing a search & replace to replace all tabs with a few spaces. Your code should look as below. Or You can easily check for problems with tabs/spaces by this command python -m tabnanny yourfile.py

Solution 1

As I think there might be spaces mixed in with your tabs. Try doing a search & replace to replace all tabs with a few spaces. Your code should look as below.

result = 1
for i in range (1,n):
    result = result * i
print "1 sum result is ",result

Solution 2

There are spaces mixed in with your tabs. If You are using a sublime text editor then just follow the below step.

  1. Open Sublime Text Editor.
  2. Open View.
  3. Then Select Indentation.
  4. Convert Indentation to Tabs.
  5. Uncheck the Indent Using Spaces option.

Solution 3

You can easily heck for problems with tabs/spaces by this command

python -m tabnanny yourfile.py

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment