How to add items from a list as values to corresponding dictionary key?
I want to sort groceries from an shopping list into categories using a dictionary. I have created the following 4 lists: DAIRY= ["milk", "cheese", "butter"] MEAT= ["steak", "ham", "sausage"] VEG= ["broccoli", "tomato", "carrot", "eggplant"] FRUIT = ["apples", "bananas", "oranges"] and the following dictionary : Shopping_List = {"VEG": [], "FRUIT": [], "MEAT": [], "DAIRY": [], "OTHER": []} When a word from the input list matches an element on one of the 4 lists, I want it to be added as a value to the corresponding key in the dictionary, e.g if the input is "bananas",which is an element of the list FRUIT, I want it to be added as a value for the dictionary key FRUIT {"FRUIT": ["bananas"]}. Furthermore, If the input word isn't on any of the lists,f it should be added as a value for the dictionary key OTHER. My goal is to create a function that does the following: With an input list,such as, this : input_list: ["bananas", "broccoli","carrot", "egg", "steak", "milk", "cookies", "water"] the function groceries (input_list) should return the following dictionary: {"VEG": ["carrot", "broccoli"], "FRUIT": ["bananas"], "MEAT": ["steak"], "DAIRY": ["milk"], "OTHER": ["cookies", "eggs", "water"]}. I am currently stuck as I don't know how to add the items from the input list to the empty value list of the matching dictionary key. I would really appreciate it if someone could give me some pointers.