Can you say what is the parameter that represents the dictionary passed to this function? And what parameter represents the tuple passed to the function? Are you using those parameters in your function?
Thanks for telling me that. I forgot to make the parameters into a tuple/dictionary. However, I still have an error with the script because I can’t turn the key/value into lowercase and I’m not sure if I have to turn the keys/values from the test settings lowercase or the keys/values from the settings parameter lowercase. Also, what would be the best way to convert them into lowercase and what would be the best operator to use (!=, ==, or something else)?
By the way, your test_settings dictionary is showing keys and values that are not lowercase. Does that make sense if add_settings always converts the key-value tuple parameter to a lowercase key and value? (And I really don’t know why the test dictionary shows English capitalized; it shouldn’t)
What parameter contains the key-value to be added to the dictionary? Are you using it here?
I see what you mean. I’ve changed the things you told me. I capitalized the values and keys because I was testing to see if the keys/values would lowercase. The key and value variables are what I used to lowercase the keys and values in the settings parameter.
I’ve figured everything out with converting key and value to lowercase. However, I can’t figure out how to solve step number 7. Take a look at the script and see if you can figure out because I sure can’t.
test_settings = {
"Volume": 43,
"Brightness": "High",
"Theme": "light",
"Notifications": "Disabled"
}
def add_setting(settings, key_value_pair):
key, value = key_value_pair
lower_key = key.lower()
lower_value = value.lower()
settings[lower_key] = lower_value
if lower_key in settings:
return f"Setting '{lower_key}' already exists! Cannot add a new setting with this name."
elif lower_key not in settings:
settings.update({lower_key:lower_value})
return f"Setting '{lower_key}' added with value '{lower_value}' successfully!"