Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I seem to be missing the tests that ask me to convert the parameters values to lowercase. I’ve built this code on VSC for my personal readability, and tested to see if I managed to successfully convert the values to lowercase. When I did, I continued with the user stories and when I was done, came back to check the code. However, I ran into this situation. After reviewing my code and browsing the forums, I couldn’t find an answer. I’d appreciate the help!

Your code so far

test_settings = {
    'theme': 'light',
    'notifications':'enabled',
    'volume':'high'
}

def add_setting(settings_dict, *items):
    key_raw, value_raw = items
    key = key_raw.lower()
    value = value_raw.lower()
    if key in settings_dict:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
        settings_dict[key] = value
        return f"Setting '{key} added with '{value} successfully!"

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

def delete_setting(settings_dict, key):
    key = key.lower()
    if key in settings_dict:
        settings_dict.pop(key)
        return f"Setting '{key}' deleted successfully!"
    else:
        return f"Setting not found!"

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.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

How did you test this? How did you prove that your function does what it says?

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

Did you test this? What does your function return?

I’ve entered the parameters as follows. I realize now that it is different from what the test analyzes, but I figured the result of the following code outputs the same result the test expects. If I understood incorrectly and the parameters should be put exactly as the test shows, then honest mistake from my part. Appreciate the help though!

print(add_setting(test_settings, 'theme', 'light'))
print(add_setting(test_settings, 'THEME', 'dark'))
#All of these output the test intended message: "Setting '[key]' already exists! Cannot add a new setting with this name."

How many arguments are you calling your function with?

Are they the correct data types?

  1. You should define a function named add_setting with two parameters representing a dictionary of settings and a tuple containing a key-value pair

Look at the test again, you need to use the EXACT SAME function call to test.

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

When I test with that function call I get an error with your code

Traceback (most recent call last):
  File "main.py", line 44, in <module>
  File "main.py", line 8, in add_setting
ValueError: not enough values to unpack (expected 2, got 1)