Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

Im lost on the view settings part i think i got it basicially figured out but i cant make it look pretty like it needs to be in order for it to pass
also delete settings is trippin me out a bit

Your code so far

#User Configuration Manager

test_settings = {
    'theme': 'dark', 
    'notifications': 'enabled', 
    'volume': 'high'
}
def add_setting(dictionary, setting):
    key, value = setting
    key = key.lower()
    value = value.lower()
    if key in dictionary:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
        dictionary[key] = value
        return f"Setting '{key}' added with value '{value}' successfully!"
    
def update_setting(dictionary, setting):
    key, value = setting
    key = key.lower()
    value = value.lower()
    if key in dictionary:
        dictionary.update({key: value})
        return f"Setting '{key}' updated to '{value}' successfully!"
    else:
        return f"Setting '{key}' does not exist! Cannot update a non-existing setting."

def delete_setting(dictionary, setting):
    key, value = setting
    key = key.lower()
    value = value.lower()
    if not key in dictionary:
        return f"Setting not found!"
    else:
        del dictionary[key]
        return f"Setting '{key}' deleted successfully!"
'''this code works but doesnt pass'''

def view_setting(dictionary):
    if dictionary == {}:
        return "No settings availible."
    if dictionary:
        for key in dictionary.items():
            
            return f"Current User Settings:\n{str(dictionary)}"    






print(view_setting(test_settings))

print(add_setting(test_settings, ('WiFi', 'ON')))

print(view_setting(test_settings))

print(update_setting(test_settings, ('theme', 'light')))

print(view_setting(test_settings))

print(delete_setting(test_settings, ('Wifi', 'ON')))

print(view_setting(test_settings))


'''def delete_setting(dictionary, key):
    key = str(key).lower()
    if key in dictionary:
        return f"Setting not found!"
        
    else: del dictionary[key]
        return f"Setting '{key}' deleted successfully!"
         '''
'''this function passed the code, but it wont work
the above code works right, but wont pass the code, im confused 
'''

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

Hi @josephg,

Here is an excerpt from the instructions:

You should define a function named delete_setting with two parameters representing a dictionary of settings and a key.

But in your function call, you are passing in a tuple as the second argument. Is that what this function expects?

Is this how we delete a dictionary item?

Is that the name of the function you have defined?

You should define a function named view_settings

I suggest going through the user stories again to make sure you have implemented them correctly.

Happy coding

woah, the s is crazy

and now that makes more sense. it makes more sense to pass it like that as well. and its cleaner