Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I don’t now whats going on my code is giving right output but still its showing errors
test_settings={‘theme’:‘dark’,‘notification’:‘enabled’,‘volume’:‘high’}

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:
test_settings.update({key:value})
return f"Setting ‘{key}’ added with value ‘{value}’ successfully!"

Your code so far

test_settings={'theme':'dark','notification':'enabled','volume':'high'}

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:
         test_settings.update({key:value})
         return f"Setting '{key}' added with value '{value}' successfully!"
   

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

def delete_setting(setting,key_value):  
    key=key_value[0].lower()
    if key in setting:
        del test_settings[key]
        return f"Setting '{key}' deleted successfully!."
    else:
        return f"Setting not found!"    

    

def view_settings(test_settings):
    str="Current User Settings:\n"
    if len(test_settings)==0:
        return "No settings available"
    else:    
        for kv in test_settings.items():
            key=kv[0].title()
            value=kv[1]
            str+=f"'{key}':'{value}'\n"
    return str 
print(add_setting({'theme':'light'},('THEME','dark')))  
print(add_setting({'theme':'light'},('Volume','high')))
print(update_setting({'theme': 'light'}, ('theme', 'dark')))
print(delete_setting({'theme': 'light'}, 'theme'))
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/144.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

I would start by making sure you are using parameters rather than global variables inside your functions. And name your parameters consistently so it’s not confusing.

Please review User Story #4 carefully. The messages returned by your functions should be exact, including punctuation.

Here are some debugging steps you can follow. Focus on one test at a time:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)

If this does not help you solve the problem, please reply with answers to these questions.