Tell us what’s happening:
In my user stories, I’ve completed 8 tasks
as requested. In the tests, line 27 isn’t being executed. Perhaps I’ve implemented view_settings incorrectly on line 33?
Your code so far
test_settings = {
"key1" : "value1",
"key2" : "value2"
}
def add_setting(a, b):
n_key, n_value = b
c_key = n_key.lower()
c_value = n_value.lower()
if c_key in a:
return "Setting 'theme' already exists! Cannot add a new setting with this name."
else:
a[c_key] = c_value
return "Setting 'volume' added with value 'high' successfully!"
def update_setting(a, b):
n_key, n_value = b
c_key = n_key.lower()
c_value = n_value.lower()
if c_key in a:
a[c_key] = c_value
return "Setting 'theme' updated to 'dark' successfully!"
else:
return "Setting 'volume' does not exist! Cannot update a non-existing setting."
def delete_setting(a, key):
c_key = key.lower()
if c_key in a:
a.pop(c_key)
return "Setting 'theme' deleted successfully!"
else:
return "Setting not found!"
def view_settings(a):
if not a:
return "No settings available."
lines = []
for key, value in a.items():
c_key = key.capitalize()
lines.append(f"{c_key}: {value}\n")
return "Current User Settings:\n" + "".join(lines) + "\n"
print(view_settings({'theme': 'dark', 'notifications': 'enabled', 'volume': 'high'}))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Challenge Information:
Build a User Configuration Manager - Build a User Configuration Manager