Hi folks,
Just hoping someone can point me in the right direction with this one.
Say I have these key:value pairs in a dictionary, d1:
d1 = {fruit:['apples', 'bananas','oranges','tomatoes'], vegetables:['carrots','lettuces']}
And I wanted to remove a list (containing tomatoes, oranges) from the value of the key fruit and add those list contents to vegetables.
fruit_veg_list = ['tomatoes','oranges']
Now I've worked out concatenations just fine, so I've got that list adding to "vegetables". That's the easy part.
Trouble is, when trying a del or remove or similar, to get rid of the fruit_veg_list values from the key fruit, I simply can't work out how to do it. This makes sense, since the list itself doesn't exist in fruit's values! Yet I can't work out a way to take those items out of the list and remove them one by one.
Is there a sort of "reverse concatenation" for this situation? I'm a bit stuck but if someone could guide me in the right direction it would be much appreciated.