Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

Hi i have already converted key to lowercase in update_setting function but i am still being prompted on it. Can’t seem to identify the issue here. Can someone please assist on this?

Your code so far

test_settings = {
    'theme': 'dark',
    'Brightness': '75',
    'Notifications': 'enabled',
    'Volume': 'high'    
}


def add_setting(settings, key_val):
    if isinstance(key_val, tuple):
        key, val = key_val
        key = key.lower()
        val = val.lower()
        print(key, val)
    for setting in settings.items():
        if key in setting:
            return f"Setting '{key}' already exists! Cannot add a new setting with this name."
            break
        else:
            settings[key] = val
            return f"Setting '{key}' added with value '{val}' successfully!"
            break



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


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


def view_setting(settings):
    if not settings:
        return 'No settings available.'
    else:
        pass

add_setting({'theme': 'light'}, ('THEME', 'dark'))
update_setting({'theme': 'light'}, ('VOLUME', 'dark'))

Your browser information:

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

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Hello @stario

There are a few issues in your code.

First, you’re incorrectly checking if key is already in the dictionnary. You’re doing :

But this is not how you’re supposed to do it. You should be doing :

removed by moderator

The way you’re doing it seems to always return False.

You’re also not updating your dictionnary correctly. You should have :

removed by moderator

By doing so, you’re correctly calling the update function and using the lowercase key.

Hope this helps.

Happy coding :slight_smile:

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.