Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

my 27th step is failing for build-a-user-configuration-manager even though i am getting the expected output

Your code so far test_settings = {‘theme’: ‘dark’,‘notifications’:‘enabled’,

‘volume’:‘high’}

def add_setting(settings,new_setting):

key = str(new_setting\[0\]).lower()

value = str(new_setting\[1\]).lower()

if key in settings:

    return F"Setting '{key}' already exists! Cannot add a new setting with this name."

else:

    settings.update({ key:value })

    return f"Setting '{key}' added with value '{value}' successfully!"

def update_setting(settings,new_setting):

key = str(new_setting\[0\]).lower()

value = str(new_setting\[1\]).lower()

if key in settings:

    settings.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(settings,new_setting):

key = str(new_setting).lower()

if key in settings:

    del settings\[key\]

    return f"Setting '{key}' deleted successfully!"

else:

    return f"Setting not found!"

def view_settings(settings):

if not settings:

    return f"No settings available."

else:

    display_setting = "Current User Settings:"

    for key, value in test_settings.items():

        setting = f"\\n{key.capitalize()}: {value.lower()}"

        display_setting += setting

    return display_setting 

print(view_settings(test_settings))

test_settings = {'theme': 'dark','notifications':'enabled',
'volume':'high'}
def add_setting(settings,new_setting):
    key = str(new_setting[0]).lower()
    value = str(new_setting[1]).lower()
    if key in settings:
        return F"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
        settings.update({ key:value })
        return f"Setting '{key}' added with value '{value}' successfully!"
def update_setting(settings,new_setting):
    key = str(new_setting[0]).lower()
    value = str(new_setting[1]).lower()
    if key in settings:
        settings.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(settings,new_setting):
    key = str(new_setting).lower()
    if key in settings:
        del settings[key]
        return f"Setting '{key}' deleted successfully!"
    else:
        return f"Setting not found!"

def view_settings(settings):
    if not settings:
        return f"No settings available."
    else:
        display_setting = "Current User Settings:"
        for key, value in test_settings.items():
            setting = f"\n{key.capitalize()}: {value.lower()}"
            display_setting += setting
        return display_setting 

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/143.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Are you sure that your output matches the expected output ? Read again the test n°27.

Your settings parameter is not being used here, and each line should end with a newline character.

Hi, I have updated each line ends with newline character still 27th step is not getting passed

def view_settings(settings):

    if not settings:

        return f"No settings available."

    else:

        display_setting = "Current User Settings:\n"

        for key, value in test_settings.items():

            setting = f"{key.capitalize()}: {value.lower()}\n"

            display_setting += setting 

        return display_setting 



print(view_settings(test_settings))

with this code also im getting the exact output.

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

are you asked to change this one in some way? verify please

1 Like

You are still using test_settings in your code rather than the parameter, settings. Also, value is already lower case in the dictionary and you were not asked to lower() it.

thank you, i changed it but still it is not getting passed

for the view function I’m using settings as the parameter, test_settings i am using as a argument to pass to View function. is there something wrong with it, please let me know

I did. You are using test_settings in the body of your function rather than the parameter, settings.

Your settings parameter is not being used here, and each line should end with a newline character.

1 Like

@dhess Thank you So Much