IndentationError: unindent does not match any outer indentation level while i am coding my discord bot

Viewed 17

sync def open_account(user):

users = await get_bank_data

if str(user.id) in users:
        return False
    else:
        users[str(user.id)] = {}
        users[str(user.id)]["wallet"] = 0
        users[str(user.id)]["bank"] = 0

    with open("mainbank.json","w") as f:
        json.dump(users,f)
    return TRUE

I am coding my discord bot and then it says IndentationError : unindent does not match any outer indentation level

1 Answers

the if and the else need to have the same indentation, so that python knows which else matches which if.

users = await get_bank_data

if str(user.id) in users:
        return False
else:
    users[str(user.id)] = {}
    users[str(user.id)]["wallet"] = 0
    users[str(user.id)]["bank"] = 0

with open("mainbank.json","w") as f:
    json.dump(users,f)
return TRUE

Related