Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I cant pass tests 18 and above, something is wrong with my delete_setting func i guess …

Your code so far

test_settings = {
    "theme3": "ligh2t",
    "test": "test2"
}
def add_setting(dictionary, setting):
    key, value = setting
    key_lower = key.lower()
    value_lower = value.lower() if isinstance(value, str) else value

    if key_lower not in dictionary:
        dictionary[key_lower] = value_lower
        return f"Setting '{key_lower}' added with value '{value_lower}' successfully!"
    else:
        return f"Setting '{key_lower}' already exists! Cannot add a new setting with this name."

def update_setting(dictionary, setting):
    key, value = setting
    key_lower = key.lower()
    value_lower = value.lower() if isinstance(value, str) else value

    if key_lower in dictionary:
        dictionary[key_lower] = value_lower
        return f"Setting '{key_lower}' updated to '{value_lower}' successfully!"
    else:
        return f"Setting '{key_lower}' does not exist! Cannot update a non-existing setting."

def delete_setting(dictionary, setting):
    key, _ = setting
    key_lower = key.lower()

    normalized = {k.lower(): k for k in dictionary}

    if key_lower in normalized:
        del dictionary[normalized[key_lower]]
        return f"Setting '{key_lower}' deleted successfully!"
    else:
        return "Setting not found!"


    

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Welcome to the forum @Bragolalaith !

Looks like you are trying to unpack two items from setting. Can you say what setting represents? Aren’t you seeing an error in the console when you call delete_setting?

print(delete_setting({'theme': 'light'}, 'theme'))

Why are you doing this?

Can you use del to remove a dictionary key/value? What method does remove a dictionary key/value pair?