Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (1.6k points)

When I compile the Python code below, I get

IndentationError: unindent does not match any outer indentation level

import sys

def Factorial(n): # Return factorial

    result = 1

    for i in range (1,n):

        result = result * i

    print "factorial is ",result

    return result


2 Answers

0 votes
by (25.1k points)

Your indentation seems to be correct, you may have mixed spaces and tabs while indenting your code. You may have used spaces while indenting one block and tabs while indenting the other. I would suggest re-indenting everything with either space or tabs.

0 votes
by (106k points)
edited by

Actually this error you are getting because you are mixing tabs and spaces. So do not do that. Specifically, the __init__ function body is indented with tabs while your on_data method is not.

To know more about this you can have a look at the following video tutorial:-

Browse Categories