Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

Hi I geeting this problem from test 27 .. I dont what’s wrong with my code . the result is the same as in the question

Your code so far

test_settings = {
    "Theme":"dark",
    "Notifications":"enabled",
    "Volume":"high"
} 

def add_setting(setting,new_setting):
    
    key = new_setting[0].lower()
    value = new_setting[1].lower()
    
    if key in setting:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
        setting.update({key:value})
        return f"Setting '{key}' added with value '{value}' successfully!"


def update_setting(setting,new_setting):
    pass
    key = new_setting[0].lower()
    value = new_setting[1].lower()
    
    if key in setting:
        setting.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(setting,key_delete):
    pass
    key = key_delete.lower()
    if key in setting:
        setting.pop(key)
        return f"Setting '{key}' deleted successfully!"
    else:
        return f"Setting not found!"

def view_settings(setting):
    
    capital = {k.capitalize():v for k,v in setting.items()}

    if not setting:
        return f"No settings available."
    else:
        return "Current User Settings:\n"+"\n".join(f"{k}: {v}" for k,v in capital.items())
    



print(add_setting(test_settings,('THEME', 'dark')))
print(update_setting(test_settings,(('theme', 'dark'))))
print(delete_setting(test_settings,'theme'))
print(view_settings({'theme': 'dark', 'notifications': 'enabled', 'volume': 'high'}))
# print(test_settings)


Your browser information:

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

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

It’s not clear if there should be a newline as the last character or not. In the example it kind of looks like there’s extra space at the bottom.

view_settings should display the correct results and end with a newline character.

The test itself says your output should end with a newline character.

1 Like

please also double check if there if you need to transform the value of the setting in some way, or not