Hi!
I’m trying to add new values to an already existing key in my dictionary.
Let’s suppose I have the following dictionary:
my_dict {
‘key_1’: ‘value_1’,
‘key_2’: ‘value_2’
}
My goal, in this example, is to add the values on this list: [‘value_3’, ‘value_4’] either to key_1 or to key_2.
More explicitly, I intend to get a new dictionary as showed below:
my_dict_2 {
‘key_1’: [‘value_1’, ‘value_3’, ‘value_4’],
‘key_2’: ‘value_2’
}
I’ve read about some approaches that suggest to replace ‘value_1’ with a new string comprised of the old value and all of the new ones with an assign activity:
my_dict(“key_1”) = my_dict(“key_1”)+", "+ “value_3”+…
Which, in turn, returns this:
my_dict_3 {
‘key_1’: ‘value_1, value_3, value_4’,
‘key_2’: ‘value_2’
}
Unfortunately this doesn’t work for me.
Does anyone know a workaround?
Thank you!