Python 2.7 IndentationError [closed]

Python expects 4 spaces or a tab to indent and align code – similar to Java expecting curly {} brackets are the start of a loop, method or class etc.

def some_function():
somecode
morecode
...

should be formatted as

def some_function():
    somecode
    morecode
    ...

It appears that your code throws an exception on line 127, so check this and indent the code as required.

def some_code():
    for i in range(1, some_value):
        some_method()

        if need_more_indent:
            indent_code()

        do_this_after_indent_code()

    this_runs_after_for_loop()

    return 'lol'

Leave a Comment