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
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.
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.
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.