Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I have absolutely no idea why these last tests are failing. Thank you for the attention.

Failed: 25. view_settings should return formatted settings for non-empty dictionary.
Failed: 27. view_settings should display the correct results and end with a newline character.

Your code so far

test_settings = {
    'theme':'high'
}

def add_setting(settings, setting_pair):
    key, value = setting_pair
    key = key.lower()
    value = value.lower()

    if key in settings:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."

    settings[key] = value
    return f"Setting '{key}' added with value '{value}' successfully!"

def update_setting(settings, setting_pair):
    key, value = setting_pair
    key = key.lower()
    value = value.lower()

    if key not in settings:
        return f"Setting '{key}' does not exist! Cannot update a non-existing setting."

    settings[key] = value
    return f"Setting '{key}' updated to '{value}' successfully!"

def delete_setting(settings, setting_key):
    key = setting_key.lower()

    if key in settings:
        del settings[key]
        return f"Setting '{key}' deleted successfully!"
    else:
        return "Setting not found!"

def view_settings(settings):
    if not settings:
        return 'No settings available.'
    
    result = ''
    for key, value in settings.items():
        formatted_key = key.capitalize()
        formatted_value = value.capitalize()
        result += f'{formatted_key}: {formatted_value}\n'
    
    return result

print (test_settings)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

What does view_settings print when you test it?

Nothing at all, unfortunately.

How are you testing it?

print (view_settings)

Doesn’t that function take an argument?

Is that how you call a function?

I’m trying:

view_settings(test_settings)

Shouldn’t you print that?

I’ve managed to make it work:

Just made it capitalize its self key → result += f"{key.capitalize()}: {value}\n"
And if result had a non null value it would begin as → result = “Current User Settings:\n”

removed
1 Like

Congratulations on solving the challenge! You should be proud of your achievement…we are! But we are removing your working solution, so it is not available to others who have not yet done the work to get there. Again, congrats!