Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

I cant get my code to pass task 27 I have cross referenced but dont understand what is going wrong can someone help?

Your code so far

test_settings = {
    "theme": "dark",
    'notification': 'enabled',
    "volume": "high"
}

# Each Key Value pair in dict_settings represents a given preference
# For example, Language: English or Notificaitons: Quiet
# Each tuple_setting is a new input to be compared to the existing dict_settings

def add_setting(dictionary, settings):
  
  key = settings[0].lower()
  value = settings[1].lower()

  if key in dictionary:
        return "Setting '" + key +  "' already exists! Cannot add a new setting with this name."
  
  else:
      dictionary[key] = value
      return "Setting '" + key + "' added with value '" + value + "' successfully!"

def update_setting(dictionary, settings):

  key = settings[0].lower()
  value = settings[1].lower()

  if key in dictionary:
      dictionary[key] = value
      return "Setting '" + key + "' updated to '" + value + "' successfully!"
  
  else:
    return "Setting '" + key + "' does not exist! Cannot update a non-existing setting."

def delete_setting (dictionary, settings):

  key = settings.lower()
  
  if key in dictionary:
    dictionary.pop(key)
    return "Setting '" + key + "' deleted successfully!"
  
  else:
    return "Setting not found!"

def view_settings(dictionary):
  if len(dictionary) == 0:
    return "No settings available."
    
  else:
    
    entries = ""
    
    for item in dictionary.items():
      entry = item[0].capitalize() + ": " + item[1] + "\n"
      entries += entry 
      
    return "Current User Settings: \n" + entries + '\n'

print(repr(view_settings(test_settings)))


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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

I have taken out repr from the print and it still doesnt work thought i should mention that

Should there be a space after the colon? Should the message end with two new lines?

1 Like