Tell us what’s happening:
Failed: 4. add_setting should convert the key to lowercase.
Failed: 5. add_setting should convert the value to lowercase.
I’ve tried multiple things, including searching here for a solution, (ex the current line that changes the variables/parameters to lowercase, although I have also tried simpler options, such as
key = key_value_pair[0].lower()
value = key_value_pair[1].lower()
Your code so far
test_settings = {
'brightness': 'low',
'battery': 72,
'notifications': True
}
def add_setting(settings, key_value_pair):
updated_pair = tuple(i.lower() if isinstance(i, str) else i for i in key_value_pair)
key = updated_pair[0]
value = updated_pair[1]
if key in settings:
return f"Setting {key} already exists! Cannot add a new setting with this name."
test_settings[str(key)] = value
return f"Setting \'{key}\' added with value \'{value}\' successfully!"
print(add_setting(test_settings, ('poWEr', 'True')))
print(test_settings)
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Build a User Configuration Manager - Build a User Configuration Manager