Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I thought I was finished, and terminal showing correct/expected display but tests 25-27 fail and error message about view_settings when non empty

Your code so far

# create dict with some values
test_settings = {
    'theme':'dark',
    'notifications':'enabled',
    'volume':'high'
}

# define function add_setting with 2 parameters 
def add_setting(settings, kv_pair):

#converting key & value to lower case
    key = kv_pair[0].lower() # in kv_pair, key at index[0]
    value = kv_pair[1].lower() # in kv_pair, value is index [1]

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

    else:
        settings.update({key:value}) # update 'settings' with key:value pair
        return f"Setting '{key}' added with value '{value}' successfully!"



# define function for update_setting again with 2 parameters
def update_setting(settings, kv_pair):
    key = kv_pair[0].lower()
    value = kv_pair[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."


# define delete_setting function
def delete_setting(settings, key):
    key = key.lower()
   
    if key in settings:
        del settings[key] # if key exists, remove from 'settings'
        return f"Setting '{key}' deleted successfully!"

    else:
        return "Setting not found!"

# define view_settings function
def view_settings(settings):
    if not settings: # 'if not' checks if empty
        return "No settings available."

    else:
        display = "Current User Settings :"
        for key, value in settings.items(): # loop over each key:value pair in 'settings' dictionary
            next_line = f"\n{key.capitalize()} : {value.lower()}" # 'case' and new line for each KV pair
            display += next_line # adding each KV pair line to inital 'display' text
        return display

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 Edg/148.0.0.0

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

look at the expected output in the instructions:

vs the output in the terminal

isn’t there something not matching here?

thanks for that. I now have all tests correct except the last one - 27. I get message, view settings should display correct result and end with a newline character. From what I can see view_settings is now displaying correct result (thanks to you!) - but I have no idea what ‘end with a newline character’ means - this may be a problem with my english , no python!

do you know what the new line character is?

only newline i know about is ’ \n’ which i used in view_setting function to ensure each line is printed separately which it is

is the box below the V in volume in your initial response important? I had only looked at the spaces and resolved those

and you used it correctly, but did you add it at the end of the string too?

thanks, I had not and am now sorted. Thanks again