3

I am trying to update a dictionary value in Python. I'm trying to update a value in the dict by subtracting 3 from the value.

if buildings == 1:
        workpower -= 3
        if workpower >= 0:
            farmplace1 = int(input("where do you want it?"))
            farmplace2 = int(input("where do you want it?"))
            board[farmplace1][farmplace2] = "F"    
            my_dict['d'] -= 3;

I get the following error

IndentationError: unindent does not match any outer indentation level

What is wrong with the code?

Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
Daniel
  • 33
  • 1
  • 1
  • 2

2 Answers2

4

Change your indentation and ensure it's consistent ( just use spaces or just use tabs, don't mix both ):

if buildings == 1:
    workpower -= 3
    if workpower >= 0:
        farmplace1 = int(input("where do you want it?"))
        farmplace2 = int(input("where do you want it?"))
        board[farmplace1][farmplace2] = "F"    
        my_dict['d'] -= 3
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
2

Check if you use regular whitespaces for all your indents, the most likely you have tab or another space character like that instead of the whitespace.

Mixing space characters may lead to nice visual indents but bad for the interpreter.

Maksym Polshcha
  • 18,030
  • 8
  • 52
  • 77