IndentationError: unindent does not match any outer indentation level
Other posters are probably correct...there might be spaces mixed in with your tabs. Try doing a search & replace to replace all tabs with a few spaces.
import sysdef Factorial(n): # return factorial result = 1 for i in range (1,n): result = result * i print "factorial is ",result return resultprint Factorial(10)
IMPORTANT:Spaces are the preferred method - see PEP008 Indentation and Tabs or Spaces?. (Thanks to @Siha for this.)
Sublime Text users:
Sublime Text to use tabs for indentation:
Convert Indentation to Tabs
Indent Using Spaces option as well in the same sub-menu above.This will immediately resolve this issue.
To easily check for problems with tabs/spaces you can actually do this:
python -m tabnanny yourfile.py
or you can just set up your editor correctly of course :-)