Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

My code seems to produce the right output, but I’m still failing task 27. Could someone help me, please?

Your code so far

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 "No settings available."
    
    lines = ["Current User Settings:"]
    for key, value in settings.items():
        
        lines.append(f"{key.capitalize()}: {value.lower()}")
    
    return "\n".join(lines) + "\n"



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



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

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager
https://www.freecodecamp.org/learn/full-stack-developer/lab-user-configuration-manager/build-a-user-configuration-manager

make sure you are printing the settings in the same order as shown in the example code

“““
Current User Settings:
Theme: dark
Notifications: enabled
Volume: high

”””
This is my output with the code I posted before; the order seems to be right.

if you want to format your code you need to use backticks `

you are right, the order is not the issue, maybe the capitalization

like, consider an input object of

{"theme": "light", "language": "English", "notifications": "enabled"}

what should be the output? I would guess English should stay English, in your code that does not happen

1 Like