Tell us what’s happening:
After reading carefully, iterating minor details, and trying different wording, I can’t seem to pass test 27…
Would love some input! I have been spending the last hour trying to find the loophole, but making no progress.
Your code so far
test_settings = {
'theme': 'dark',
'language': 'english',
'notifications': 'enabled'
}
#adding
def add_setting(set_dict,tup_pair):
key, value = tup_pair
l_key = key.lower()
l_val = value.lower()
if l_key in set_dict.keys():
return f"Setting '{l_key}' already exists! Cannot add a new setting with this name."
set_dict.update({l_key: l_val})
return f"Setting '{l_key}' added with value '{l_val}' successfully!"
#updating
def update_setting(dictionary,tup_pair):
key, value = tup_pair
l_key = key.lower()
l_val = value.lower()
if l_key in dictionary.keys():
dictionary.update({l_key: l_val})
return f"Setting '{l_key}' updated to '{l_val}' successfully!"
return f"Setting '{l_key}' does not exist! Cannot update a non-existing setting."
#deleting
def delete_setting(dictionary, key):
l_key = key.lower()
if l_key in dictionary.keys():
dictionary.pop(l_key)
return f"Setting '{l_key}' deleted successfully!"
return 'Setting not found!'
#viewing
def view_settings(dictionary):
if not bool(dictionary):
return 'No settings available.'
new_str = ''
for keys, values in dictionary.items():
test = (f'{keys}: {values}')
cap_str = test.capitalize()
new_str += f'{cap_str}\n'
return f"Current User Settings:\n{new_str}"
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/145.0.0.0 Safari/537.36
Challenge Information:
Build a User Configuration Manager - Build a User Configuration Manager