-5

I am getting an IndentationError when trying to run my program in a Python Interpreter:

 line 127
    global map
         ^
IndentationError: expected an indented block

I am using python version 2.7

What's wrong with the following code?:

def make_map():
global map
reevesy
  • 3,452
  • 1
  • 26
  • 23

1 Answers1

0

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'
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65