Build a User Configuration Manager-Task 27

I can’t get task 27 to complete. I have cross-referenced with other people’s code and can’t figure it out. Does anyone know what I’m doing wrong?

def add_setting(settings, new_setting):

    key = str(new_setting\[0\]).lower()

    value = str(new_setting\[1\]).lower()



if key in settings:

return f"Setting '{key}' already exists! Cannot add a new setting with this name."

else:

        settings.update({ key:value })

return f"Setting '{key}' added with value '{value}' successfully!"





def update_setting(settings, new_setting):

    key = str(new_setting\[0\]).lower()

    value = str(new_setting\[1\]).lower()



if key in settings:

        settings.update({ key:value })

return f"Setting '{key}' updated to '{value}' successfully!"

else:

return f"Setting '{key}' does not exist! Cannot update a non-existing setting."





def delete_setting(settings, new_setting):

    key = str(new_setting).lower()

if key in settings:

del settings\[key\]

return f"Setting '{key}' deleted successfully!"

else:

return f"Setting not found!"




def view_settings(settings):

if not settings:

return "No settings available."

    lines = \["Current User Settings:"\]

for key, value in settings.items():

        lines.append(f"{key.capitalize()}: {value.lower()}")

return "\\n".join(lines) + "\\n"





test_settings = {'theme': 'dark','notifications':'enabled',

'volume':'high'}





print(view_settings(test_settings))

Can you please add a link to the step you are on?

What is task 27?

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

I’ve edited your post to improve the readability of the code. However it was already mangled when you pasted it in this thread, losing some characters and indentation.

Ideally you can post the code again into a new reply here.

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').