Python throws the error, IndentationError: unindent does not match any outer indentation level, When you mix spaces and tabs in the same code. You can either use tabs or spaces but not both. Also, it is recommended to use spaces.

Consider this code example –

def SuperHero(ind):
	superList = ["Captain Americal", "Ironman", "Thor", "Hulk"];
    if(ind >=0 and ind < len(superList)):
        return superList[ind];
        return "Error: Index out of bounds";


This code will throw the error that, “IndentationError: unindent does not match any outer indentation level” because in superList line, I have used tab for spacing while everywhere else I have used spaces. It’s not visible because I have used equal number of spaces as that of tab.

To solve this you need to remove the tab with spaces but for that you need to know where we have used tab in the code. Simple find and replace in text editors will help. Search for tab and replace with 4 spaces.

    Tweet this to help others


About the Author


I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles