Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python IndentationError: unindent does not match any outer indentation level [duplicate]

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?

like image 345
Daniel Avatar asked Apr 16 '26 19:04

Daniel


1 Answers

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
like image 185
AK47 Avatar answered Apr 18 '26 07:04

AK47



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!