Tell us what’s happening:
Right now I just need help with the add_setting() function. For some reason it doesn’t pass tests 4,5 7&8 even though I’m pretty sure I am indeed converting the values to lower case and adding the key_value pair to the new dictionary. Maybe I’m not returning it correctly?
Your code so far
current_settings = {
'Theme':"dark",
"Notifications": "enabled",
"Volume": "hight"
}
test_settings = {
"Theme": "light",
"Notificatiosn": "disabled",
"Volume": "Medium"
}
#settings paramater is the dictionary created, key_value is the values added
def add_setting(settings, key_value):
#converts settings parameter key to lowercase
lowered_setting= []
for key in settings.keys():
lowered_setting.append(key.lower())
#converts key_value's key in to lowercase:
lowered_key = key_value[0].lower()
#converts key_value's value in to lowercase:
lowered_value = key_value[1].lower()
#checks if "settings" parameter key exists
for i in range(len(lowered_setting)):
if lowered_key == lowered_setting[i]:
return f"Setting '{key_value[0].lower()}' already exists! Cannot add a new setting with this name."
settings[lowered_key.capitalize()] = key_value[1].lower()
return f"Setting '{key_value[0].lower()}' added with value '{key_value[1].lower()}' succesfully!"
print(add_setting(current_settings, ("Accents", "red")))
#just checking to see that the key value pair added was indeed added:
print(current_settings)
def update_setting(settings,key_value):
pass
def delete_setting(settings, key):
pass
def view_settings(settings):
pass
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 Edg/144.0.0.0
Challenge Information:
Build a User Configuration Manager - Build a User Configuration Manager
