Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

The output is showing correctly on the console but when I’m clicking on test code it’s asking me to convert the key to lowercase in update_setting. I have done that as well I’m not sure why It’s saying that. Can someone please tell me what’s going wrong?

Your code so far

def add_setting(settings,pair):
    input_key=pair[0].lower()
    input_value=pair[1].lower()
    for key in settings:
        key=key.lower()
        if input_key == key:
            found = True
            break
        else:
            found = False
        continue
    if found:
        return f"Setting '{input_key}' already exists! Cannot add a new setting with this name."
    if not found:
        new_setting={input_key:input_value}
        settings.update(new_setting)
        return f"Setting '{input_key}' added with value '{input_value}' successfully!"
        
        #print(settings)

def update_setting(settings,pair):
    input_key=pair[0].lower()
    input_value=pair[1].lower()
    for key in settings:
        key=key.lower()
        if input_key == key:
            found = True
            break
        else:
            found = False
        continue
    if found:
        settings[input_key.title()]=input_value
        return f"Setting '{input_key}' updated to '{input_value}' successfully!"
    if not found:
        
        return f"Setting '{input_key}' does not exist! Cannot update a non-existing setting."

def delete_setting(settings,pair):
    input_key=pair[0].lower()
    input_value=pair[1].lower()
    for key in settings:
        key=key.lower()
        if input_key == key:
            found = True
            break
        else:
            found = False
        continue
    if found:
        del settings[input_key.title()]
        return f"Setting '{input_key}' deleted successfully!"
    if not found:
        return "Setting not found!"

def view_settings(settings):
    if settings == {}:
        return "No settings available."
    else:
        output = ""
        #print("Current User Settings:")
        for setting, mode in settings.items():
            output += f"{setting.title()}: {mode}\n"
    return output


test_settings={
    'Current User Settings':'',
    'Theme': 'dark',
    'Notifications': 'enabled',
    'Volume': 'high'
}

User_input = ('background','blue')
add_setting(test_settings,User_input)
#print(test_settings)
add_setting(test_settings,User_input)
print(update_setting({'theme': 'light'},("theme","dark")))
#print(test_settings)
delete_setting(test_settings,('volume', 'high'))
#print(test_settings)

print(view_settings(test_settings))

Your browser information:

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

Why are you lowering the key here if key/value pairs added to the dictionary are always lowercase?

Why are you capitalizaing the key here? Same reason as above.

Please review the user stories for delete_setting. Should the second parameter be a tuple?

Is this the correct way to delete a key/value pair from a dictionary?

i had created a dictionary with capital first letters so that’s why I had added the .lower() and .title() I fixed it now thanks!