Build a User Configuration Manager - Build a User Configuration Manager (Fails Delete and View)

Tell us what’s happening:

I am not sure why I keep failing the tests, when It passes everything I throw at it. Please help. I left notes in the code.

Fails: 18,19,21,25,27

Your code so far

test_settings = {
    'theme': 'dark',
    'notifications': 'enabled',
    'volume':'high'
}
ts = {}
#{k.lower(): v for k, v in alphabet.items()}
def add_setting(setting,key_value):
    key = key_value[0].lower()
    value = key_value[1].lower()
    if key in setting:
        return f"Setting '{key}' already exists! Cannot add a new setting with this name."
    else:
        setting.update({key:value})
        return f"Setting '{key}' added with value '{value}' successfully!"
def update_setting(setting,key_value):
    key = key_value[0].lower()
    value = key_value[1].lower()
    key = key.lower()
    value = value.lower()
    if key not in setting:
        return f"Setting '{key}' does not exist! Cannot update a non-existing setting."
    
    setting[key] = value
        #print (test_settings)
    return f"Setting '{key}' updated to '{value}' successfully!"

def delete_setting(setting,key_value):
    #Fails 18,19,21
    print('Settings to be deteleted: ',key_value,'\n')
    key = str(key_value[0]).lower()
    #value = str(key_value[1])
    key = str(key).lower()
    #value = value.lower()
    print('Key to be delete:',key,'\n') #theme
    print ('Settings after made lowercase: ',setting,'\n')#{'theme': 'dark','notifications': 'enabled','volume':'high'}

    if key in setting:
        #setting.pop(key,value)
        del setting[key]
        print ('Key has been removed: ',setting,'\n') # {'notifications': 'enabled','volume':'high'}
        return f'Setting "{key}" deleted successfully!'
    else:
        return "Setting not found!"

def view_settings(setting):
    #fails 25,27
    p_out = ""
    header = "Current User Setting: \n"
    if setting:    
        for key,value in setting.items():
            k= key.capitalize()
            v = value.lower()
            p_out +=  k + ": " + v + '\n'
        return header + p_out
    else:
         return "No settings available."

#print(add_setting(test_settings,('Theme','light')))
#print(f"{test_settings}\n")
#print(update_setting(test_settings,('Theme','light')))
#print(f"{test_settings}\n")
#print('\n')
print(delete_setting(test_settings,('Theme','lIght')),'\n')
#print('\n')
#print(f"{test_settings}\n")
print(view_settings(test_settings))
#print(view_settings(ts))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Welcome to the forum @brian86!

Does this match exactly to the text in the instructions? And should there be a space after the colon?

Why are you applying the str() method? Isn’t the key already a string?

Is this the correct way to remove a dictionary item? What dictionary method should you use instead?

Working with Dictionaries and Sets - What Are Dictionaries, and How Do They Work? | Learn | freeCodeCamp.org

What type of quotes should be wrapped around key in this message?

Please review User Story #5. Does key_value represent just the key?

Happy coding!

Solved.

removed by mod

Congratulations on solving the challenge! You should be proud of your achievement…we are! But we are removing your working solution, so it is not available to others who have not yet done the work to get there. Again, congrats!