Tell us what’s happening:
Re: Steps 25 - 27… I appear to be getting the correct outputs, but the tests are not passing. Can someone please help me troubleshoot the issue? Thanks! - Sam
Your code so far
test_settings = {
"on": True,
"off": False
}
def add_setting (dictionary_of_settings, key_value_pair_tuple):
key, value = key_value_pair_tuple
key = key.lower()
value = value.lower()
if key in dictionary_of_settings:
return f"Setting '{key}' already exists! Cannot add a new setting with this name."
else:
dictionary_of_settings[key] = value
return f"Setting '{key}' added with value '{value}' successfully!"
def update_setting (dictionary_of_settings, key_value_pair_tuple):
key = key_value_pair_tuple[0].lower()
value = key_value_pair_tuple[1].lower()
if key in dictionary_of_settings:
dictionary_of_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."
update_setting({"theme": "light"}, ("theme", "dark"))
update_setting({'theme': 'light'}, ('volume', 'high'))
def delete_setting (dictionary_of_settings, key):
key = key.lower()
if key in dictionary_of_settings:
dictionary_of_settings.pop(key)
return f"Setting '{key}' deleted successfully!"
else:
return "Setting not found!"
def view_settings(dictionary_of_settings):
if not dictionary_of_settings:
return "No settings available."
else:
entries = ""
for setting, value in dictionary_of_settings.items():
entry = f"{setting.capitalize()} : {value}\n"
entries += entry
return f"Current User Settings:\n{entries}"
print(repr(view_settings(test_settings)))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36
Challenge Information:
Build a User Configuration Manager - Build a User Configuration Manager