Build a User Configuration Manager - Build a User Configuration Manager

Tell us what’s happening:

i can’t pass tests 4, 5, 7, 8, 11, 15, 18, 21, 24
very confused, what’s wrong with my code?

Your code so far

test_settings = {'theme': 'light'}

def add_setting(settings_dict, key_value_pair):
    addedkey = key_value_pair[0]
    withvalue = key_value_pair[1]
    for key in settings_dict.keys():
        if addedkey.lower() in settings_dict.keys():
            return f"Setting '{key.lower()}' already exists! Cannot add a new setting with this name."
        else:
            settings_dict[addedkey.lower()] = withvalue.lower()
            return f"Setting '{addedkey.lower()}' added with value '{withvalue.loer()}' successfully!"

def update_setting(settings_dict, key_value_pair):
    updatedkey = key_value_pair[0]
    upwithvalue = key_value_pair[1]
    for key in settings_dict.keys():
        if updatedkey in settings_dict.keys():
            settings_dict.update({key.lower(): upwithvalue.lower()})
            return f"Setting '{key.lower()}' updated to '{upwithvalue.lower()}' successfully!"
        else:
            return f"Setting '{updatedkey}' does not exist! Cannot update a non-existing string"

def delete_setting(settings_dict, key_value_pair):
    deletedkey = key_value_pair
    for key in settings_dict.keys():
        if deletedkey in settings_dict.keys():
            settings_dict.pop(key.lower())
            return f"Setting '{deletedkey.lower()}' deleted successfully!"
        else:
            return "Setting not found!"

def view_settings(settings_dict):
    if not settings_dict:
        return "No settings available"
    else:
        result = "Current User Settings:\n"
        for key, value in settings_dict.items():
            result += f"{key.capitalize()}: {value.lower()}\n"
        return result

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:148.0) Gecko/20100101 Firefox/148.0

Challenge Information:

Build a User Configuration Manager - Build a User Configuration Manager

Welcome to the forum @mariomaa987 !

How are you testing your functions? I don’t see any function calls.

Happy coding!

oh i would just call a function to see if it works and delete it after, it seemed to be working fine. would it work to maybe store the value resulted from a function into a certain other dictionary??

Test #7 shows an example of a function call:
add_setting({'theme': 'light'}, ('volume', 'high'))

You will need to wrap that function call in a print() so you can see what is returned in the console.

Test your code, please.

actually now that i reread the code it turns out i just had a typo in the first function and a bunch of mistakes in the others. to my defense i was low on sleep when i wrote that and opened this forum
that one does print “Setting ‘volume’ added with value ‘high’ successfully!” and now im fixing the rest of the code and its working. thanks for your help anyway

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.