Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I have a couple of things that bother me, I reviewed my code multiple times but cannot find where and how I was mistaken.

For one, n7 (add_setting) should add a new key-value pair.
settings[key] = value, updates value and key
if i give key and value names (as in, volume and high) it doesn’t go through

Your code so far

test_settings = {
'theme': 'light', 
'notifications': 'enabled', 
'volume': ''
}
    

def add_setting (settings, key_value):
    key, value = key_value
    key = key.lower()
    value = value.lower()

    # checks if key setting already exists
    if key in settings:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."

    # adds key-value pair if key setting doesn't exist
    settings[key] = value
    return f"Setting '{key}' added with {value}successfully!."

def update_setting (settings, key_value):
    key, value = key_value
    key = key.lower()
    value = value.lower()

   # if key setting exists, updates its value
    if key in settings: 
        settings[key] = value
        return f"Setting '{key}' updated to '{value}' successfully!"

   # if key setting doesn't exist 
    if key not in settings:
        return f"Setting '{key}' does not exist! Cannot update a non-existing setting."

def delete_setting(settings, key):
    key = key.lower()

    #if key doesn't exist
    if key not in settings:
        return('Setting not found!')

    # if key exists
    del settings[key]
    return f"Setting '{key}' deleted successfully!"


def view_settings (settings):
    #checks if dictionary is empty
    if not settings:
        return('No settings available.')
    #if dictionary is not empty, returns a string
    else:
        for key, value in settings.items():
            return ("Current User Setting: {key.capitalize()}: {value}\n")
            

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.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

Next, view_settings doesn’t go though as well. n25 to n27
1)should return formatted settings for non-empty dictionary.
else means do something if dictionary not empty
2)should capitalize the first letter of each setting name.
{key.capitalize()}: {value}\n" - capitalizes each key, like test asks us to do
3)should display the correct results and end with a newline character.
return string with results that test is asking for but it doesn’t go through

Hey @Linbene,

I’d suggest running your code and identifying the problem by looking at the output. Make sure the output is equivalent to what the instructions say.

Happy coding!

I added a print with the function call from test 7

see in the terminal, is that the message requested by the instructions?

I’ve changed the category of your topic to better reflect its content.