Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

Project: Issue displaying correct results in Step 27
Hi, I’m having a problem with Step 27. I’m not sure what I’m doing wrong because I don’t see any errors on my side. The task keeps saying: “27. view_settings should display the correct results and end with a newline character.” As far as I can tell, I have already implemented that requirement. Could you please help me understand what might be causing this issue?

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

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Welcome to the forum @iwaniecartur14 !

Did the instructions ask you to lower() the value? Does that even make sense since both add_setting and update_setting lower() both the key and value before they are added to the dictionary?

Remember that when you use someone else’s code from the forum, you’re also getting their errors.

1 Like

Hi, thanks for the welcome and for the help!
The solution turned out to be really simple. I completely missed that there shouldn’t be lower() there. After my code kept not working, I looked through the forum a few times to see what I might be doing wrong, and that part probably confused me. Thanks for pointing it out!

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