Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

Hello, I hope you are well.

For me, only test 27 doesn’t pass, it says:
“view_settings should display the correct results and end with a newline character.”

But I think it should be in there, I included the newline character in my part with entry and entries. To test, I tried adding characters before and after the newline to see how they showed up and from that, it seems like the newline is the last character.
Still test 27 does not pass.

What am I doing wrong?

Your code so far

# user configuration manager

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

def add_setting(dictionary, settings):
    key = settings[0].lower()
    value = settings[1].lower()
    if key in dictionary:
        return "Setting '" + key +  "' already exists! Cannot add a new setting with this name."
    else:
        dictionary[key] = value
        return "Setting '" + key + "' added with value '" + value + "' successfully!"

def update_setting(dictionary, settings):
    key = settings[0].lower()
    value = settings[1].lower()
    if key in dictionary:
        dictionary[key] = value
        return "Setting '" + key + "' updated to '" + value + "' successfully!"
    else:
        return "Setting '" + key + "' does not exist! Cannot update a non-existing setting."

def delete_setting(dictionary, setting):
    key = setting.lower()
    if key in dictionary:
        dictionary.pop(key)
        return "Setting '" + key + "' deleted successfully!"
    else:
        return "Setting not found!"

def view_settings(dictionary):
    if len(dictionary) == 0:
        return "No settings available."
    else:
        entries = ""
        for item in dictionary.items():
            entry = item[0].capitalize() + ": " + item[1] + "\n"
            entries += entry
        return "Current User Settings: \n" + entries
               
# add_setting(test_settings, ('EMOJI', 'SMALL'))

# update_setting(test_settings, ('EMOJI', 'SMALL'))

# delete_setting(test_settings, 'THEME')

view_settings(test_settings)

print(view_settings(test_settings))

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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

If you pass string before printing to the repr function - like: print(repr(view_settings(test_settings))) - there will be displayed a printable representation of the string. Showing ie. new line characters as \n, instead of actually printing new lines.

This is the repr of what function returns:

"Current User Settings: \nTheme: light\nLanguage: English\nNotifications: enabled\n"

While this is the repr of what is expected:

"Current User Settings:\nTheme: light\nLanguage: English\nNotifications: enabled\n"
1 Like

Thank you! It was a space after the first line.