Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I am a bit stuck on test 11 and 12. Maybe it’s because I used the same code for add_setting and update_setting? However, when I tried something other than key and value, it came back with the same failed test.

I did test the output using print. I shows that DARK becomes dark and that VOLUME becomes volume. So it is converting the key an value to lowercase. But I can’t seem to figure out why it isn’t passing.

Your code so far

test_settings = {
    'theme': 'light',
}
def add_setting(setting, key_value):
    key = key_value[0].lower()
    value = key_value[1].lower()
    if key in setting:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
        setting[key] = value
        return f"Setting '{key}' added with value '{value}' successfully!"

def update_setting(update, key_value):
    key = key_value[0].lower()
    value = key_value[1].lower()
    if key in update:
        return f"Setting '{key}' updated to '{value}' successfully!"
    else:
        return f"Setting '{key}' does not exist! Cannot update a non-existing setting."

print (update_setting({'theme': 'light'}, ('theme', 'DARK')))
print(update_setting({'theme': 'light'}, ('VOLUME', 'high')))

def delete_setting(delete, key_value):
    key = key_value[0].lower()
    value = key_value[1].lower()
    if key not in delete:
        return f"Setting '{key}' 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/148.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-user-configuration-manager/684aaf9ec670c68d20efd0d0.md at main · freeCodeCamp/freeCodeCamp · GitHub

test your function like this

settings = {'theme': 'light', 'language': 'English'}
print(repr(update_setting(settings, ('THEME', 'dark'))))
print(settings)

settings does not look updated to me after the function runs

Oh! I now see where I missed something in the code.