Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I dont understand, i have done what is required but it still does not pass? im not quite sure what else i have to do

Your code so far

test_settings = {
        'theme': 'light',
        'language': 'portuguese',
        'notifications': 'off',
    }

settings = [test_settings]

def add_setting(dictionary, key_value):
    key, value = key_value
    key = key.lower()
    value = value.lower()

    if key in dictionary:
        print(f"Setting '{key}' already exists! Cannot add a new setting with this name.".lower())
        return False
    else: 
        dictionary[key] = value
        print(f"Setting '{key}' added with value '{value}' successfully!".lower())
        return True

add_setting({'theme': 'light'}, ('THEME', 'dark'))
add_setting({'theme': 'light'}, ('volume', 'high'))

def update_setting(dictionary, key_value):

    key_update, value_update = key_value
    key_update = key_update.lower()
    value_update = value_update.lower()
    

    if key_update in dictionary:
        dictionary[key_update] = value_update
        print(f"Setting '{key_update}' updated to '{value_update}' successfully!")
        return True
    else:
        print(f"Setting '{key_update}' does not exist! Cannot update a non-existing setting.")
        return False

update_setting({'theme': 'light'}, ('theme', 'dark'))
update_setting({'theme': 'light'}, ('volume', 'high'))


def delete_setting(dictionary, key):

        key = key.lower()
        

        if key not in dictionary:
            print("Setting not found!")
            return False
    
        del dictionary[key]
        print (f"Setting '{key}' deleted successfully!")
        return True

delete_setting({'theme': 'light'}, 'theme')
delete_setting({'theme': 'light'}, 'stuff')
print(test_settings)

def view_settings(dictionary):
    if not dictionary:
        return "No settings available.\n"
    
    output = ["Current User Settings:"]
    for key, value in dictionary.items():
        output.append(f"{key.capitalize()}: {value}")
    return "\n".join(output) + "\n"


print(view_settings({}))
print(view_settings({'theme': 'dark', 'notifications': 'enabled', 'volume': 'high'}))



    


    

Your browser information:

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

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Here are some troubleshooting steps you can follow. Focus on one test at a time:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the first failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)

If this does not help you solve the problem, please reply with answers to these questions.

an example of how you could debug your code

the first failing test is

add_setting({'theme': 'light'}, ('THEME', 'dark')) should return the error message Setting 'theme' already exists! Cannot add a new setting with this name. .

you then write print(add_setting({'theme': 'light'}, ('THEME', 'dark'))) in your editor to see what it returns and see that it returns setting 'theme' already exists! cannot add a new setting with this name., so you need to see the differences and fix them

i have those errors, but my code is showing up correctly on the console

Make sure its exactly the same including Capitalization.

The messages returned should have the key and value in lowercase. But it is in lowercase, and in the end when it says : If the dictionary contains any settings, return a string displaying the settings. The string should start with Current User Settings: followed by the key-value pairs, each on a new line and with the key capitalized. For example, view_settings({'theme': 'dark', 'notifications': 'enabled', 'volume': 'high'}) should return: its capitalized, so… even then

What is the required output for Test 6?

this is the text that should be outputted:

this is the actual output:

they are not the same

1 Like

you are right… i was printing instead of returning, thank you all for the help