Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

i have problem with 25 view settings should return formatted settings for non empty dictionary
and 27 view_settings should display the correct results and end with a newline character
def view_settings(settings):
if settings == {}:
return “No settings available.”
else:
result = “Current User Settings:\n”
for key,value in settings.items():
result += f"{key.capitalize()}:{value}\n"
return result

Your code so far

test_settings ={"theme": "blue",
"notifications": "enabled",
"volume": "low"}

def add_setting(settings,tup):
    key,value = tup
    new_key = key.lower()
    new_value = value.lower()
    if new_key in settings:
        return f"Setting '{new_key}' already exists! Cannot add a new setting with this name."
    settings[new_key] = new_value
    return f"Setting '{new_key}' added with value '{new_value}' successfully!"

def update_setting(settings,tup):
    key,value = tup
    new_key = key.lower()
    new_value = value.lower()
    if new_key in settings:
        settings[new_key] = new_value
        return f"Setting '{new_key}' updated to '{new_value}' successfully!"
    else:
        return f"Setting '{new_key}' does not exist! Cannot update a non-existing setting."

def delete_setting(settings,key):
    new_key = key.lower()
    if new_key in settings:
        del settings[new_key]
        return "Setting 'theme' deleted successfully!"
    else:
        return "Setting not found!"

def view_settings(settings):
    if settings == {}:
        return "No settings available."
    else:
        result = "Current User Settings:\n"
        for key,value in settings.items():
            result += f"{key.capitalize()}:{value}\n" 
        return result
     
    
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/148.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-user-configuration-manager/684aaf9ec670c68d20efd0d0.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @seunbaba!

Look closely at what the instructions show for the function call to view_settings compared to yours:

From the instructions:

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

What your code is returning:


Current User Settings:
Theme:blue
Notifications:enabled
Volume:low

See the difference?

Happy coding!

i updated the test settings but 25 and 27 still not ticked off

Please post your updated code formatted as explained here:

There are two ways you can format your code to make it easier to read and test:

  1. After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)

  1. Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.

To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:

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

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

25 and 27 still not ticked off

What was the difference you noticed between what the instructions expected and what your code returned, and what did you change to fix that? You didn’t just change the dictionary values, did you? That’s not the issue. The issue is spacing.