Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

Right now I just need help with the add_setting() function. For some reason it doesn’t pass tests 4,5 7&8 even though I’m pretty sure I am indeed converting the values to lower case and adding the key_value pair to the new dictionary. Maybe I’m not returning it correctly?

Your code so far

current_settings = {
    'Theme':"dark",
    "Notifications": "enabled",
    "Volume": "hight"
}

test_settings = {
    "Theme": "light",
    "Notificatiosn": "disabled",
    "Volume": "Medium"
}

#settings paramater is the dictionary created, key_value is the values added
def add_setting(settings, key_value):
    #converts settings parameter key to lowercase
    lowered_setting= []
    for key in settings.keys():
        lowered_setting.append(key.lower())

    #converts key_value's key in to lowercase:
    lowered_key = key_value[0].lower()

    #converts key_value's value in to lowercase:
    lowered_value = key_value[1].lower()

    #checks if "settings" parameter key exists
    for i in range(len(lowered_setting)):
        if lowered_key == lowered_setting[i]:
            return f"Setting '{key_value[0].lower()}' already exists! Cannot add a new setting with this name."   
    settings[lowered_key.capitalize()] = key_value[1].lower()
    return f"Setting '{key_value[0].lower()}' added with value '{key_value[1].lower()}' succesfully!"

            
print(add_setting(current_settings, ("Accents", "red")))

#just checking to see that the key value pair added was indeed added:
print(current_settings)

def update_setting(settings,key_value):
    pass

def delete_setting(settings, key):
    pass

def view_settings(settings):
    pass


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 Edg/144.0.0.0

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

First, if you are always adding lowercased key/value pairs to your dictionary, does it make sense to have test dictionaries with capitalized key/values?

In other words, why are you doing this?

I just did that because in the “current settings” example of the module, the keys were capitalized and in order to check if the added key was in the dictionary, I assume you have to convert both the dictionary key and the added key to lowercase in order to correctly compare them?

Are you referring to User Story #8? If so, read that through again.

I was more so referring to the snippet included, it shows the dictionaries keys as capitalized, which is why I thought I would have to convert them back into lowercase to compare them to added values? Are the dictionary’s keys supposed to be in lowercase? The snippet is not from the console but from the modules instructions as an example of what the users current settings were

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.