Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I have some trouble understandig the problems here.
For starters, I don’t get why I have to set the variable key, value = pair and not the other way around.
Then I don’t really get how to turn key and value in lower case. I know I have to change the parameter settings but I don’t know how to access them.
And why the quotationmarks are shown in the terminal? I thought they were obligatory for a dictionary?

Maybe someone could help me out here. Thanks!

Your code so far

test_settings = ({'theme': 'Dark'})


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

new_setting = ('volume', 90)
add_setting(test_settings, new_setting)
print(test_settings)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.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

Hi @patrick.weissler,

That syntax is used to unpack the tuple values into variables.

This is the correct way to do that.

Please review this theory lecture:
Working with Dictionaries and Sets - What Are Dictionaries, and How Do They Work? | Learn | freeCodeCamp.org

Here’s an excerpt from that:

To update a value, you just need to add the assignment operator, followed by the new value.

pizza['name'] = 'Margherita'

Happy coding

Thank you for your help!

As I see it, I’m right with my code for the lower case? Like I define value as “settings[key]” and set key = key.lower(). But still, the test says I have to convert both to lower case. That is what I don’t get here. Or am I so wrong I don’t even see the problem? :smiley:

My first question was about the “order of the words”. In my mind it would make way more sens to write “pair = key, value” to unpack the argument in the funktion. Of course, if that is the right syntax, there is nothing to argue about. But to me, the other way around makes more sense somehow.

You already have the value from your pair tuple when you do this: key, value = pair

What you are doing here is changing the settings dictionary value for the key property, which is a bit premature since you haven’t yet lowered value or checked to see if the key is in settings.