Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

test_settings={‘theme’:‘dark’,‘notification’:‘enabled’,‘volume’:‘high’}

def add_setting(setting,key_value):
key=key_value[0]
key=key.lower()
value=key_value[1]
value=value.lower()
if key in test_settings:
return f"Setting ‘{key}’ already exists! Cannot add a new setting with this name."
else:
test_settings[key]=value
f"Setting ‘{key}’ added with value ‘{value}’ successfully!"

def update_setting(x,y):
pass

def delete_setting(x

Your code so far

test_settings={'theme':'dark','notification':'enabled','volume':'high'}

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



    

def update_setting(x,y):
    pass

def delete_setting(x,y):  
    pass

def view_settings(x,y):
    pass      
print(add_setting(test_settings,('THEME','dark')))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Hi @arti.patel09

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

Happy coding

well i have converted key and value to lower case but still its asking to convert it to lower case

test_settings={'theme':'dark','notification':'enabled','volume':'high'}



def add_setting(setting,key_value):

    #key, value = (item.lower() for item in key_value)

    key=key_value\[0\].lower()

    value=key_value\[0\].lower()

    if key in setting:

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

    else:

         test_settings\[key\]=value

         f"Setting '{key}' added with value '{value}' successfully!"

   



def update_setting(settings,key_value):

    key, value = (item.lower() for item in key_value)

    if key in settings:

        test_settings\[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(x,y):  

    pass



def view_settings(x,y):

    pass 

test_settings = {

    "brightness": 80,

    "volume": 57,

    "screen_mode": "dark",

    "theme": "dark"

}     

print(add_setting(test_settings,('THEME','dark')))

print( update_setting({'theme': 'light'}, ('theme', 'dark')))

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Where do the instructions ask the values to be converted to lower case?

step 4 and 5 ask to convert into lower case

Try printing the key and value after converting them to lowercase to make sure it happened correctly

Is test_settings the name of the parameter in the add_settings function definition?

Tell us what’s happening:

I’m not sure why tests 4 and 5 are currently not accepting.

I made sure key and value are lower cased.

Your code so far

test_settings={'theme':'dark','notification':'enabled','volume':'high'}

def add_setting(setting,key_value):
    #key, value = (item.lower() for item in key_value)
    key=key_value[0].lower()
    value=key_value[0].lower()
    if key in setting:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
         test_settings[key]=value
         f"Setting '{key}' added with value '{value}' successfully!"
   

def update_setting(settings,key_value):
    key, value = (item.lower() for item in key_value)
    if key in settings:
        test_settings[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(x,y):  
    pass

def view_settings(x,y):
    pass 
test_settings = {
    "brightness": 80,
    "volume": 57,
    "screen_mode": "dark",
    "theme": "dark"
}     
print(add_setting(test_settings,('THEME','dark')))
print( update_setting({'theme': 'light'}, ('theme', 'dark')))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Please do not create duplicate topics for the same challenge/project question(s). If you need more help then respond back to the original topic you created with your follow up questions and/or your updated code and question.
This duplicate topic has been unlisted.

Thank you.

Log value. Is that what you are expecting?

removed by moderator

first try to simplify and do it in this form and then you can go about optimising it in a single line of code after you understand.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.