Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using python3 to solve the problem Complete the shopping function, which takes two arguments: a dictionary that maps store products to prices (the keys are
Using python3 to solve the problem
Complete the shopping function, which takes two arguments: a dictionary that maps store products to prices (the keys are strings that represent product names, while the values are integers representing the product prices) and a list of products (strings) that a person wants to buy. The list might contain products not for sale at the store. The function uses the dictionary and the list to compute how much the shopping trip will cost. As an example, suppose the dictionary products is defined as ("toothbrush": 2, "comb": 3, "soap": 5, "brush": 7, "shampo": 10) and the list shopping list is defined as l"shampoo", "brush", "shampoo", "soap", "soap", "dog food", "soap" For these inputs, shopping (products, shopping list) will return 42. Note that the item "dog food" is not for sale at the store, yet the function can still compute and return the total without crashing. Also note that some items (shampoo and soap) were purchased multiple times; this is reflected in the totalcost. You may assume that product names are CASE-SENSITIVE Examples: unction Ca shopping ("s "toothbrush"2, "shampoo""brush" "shampoo",soap"ap", "dog food","soap"1 shopping "shampoo" 10, "soap": "toothbrs 2, ["candybrush", "brush"oap", fruit, "soap"1) shopping ("sh "toothbrush":21, "wood" "paint","shovel",mop 1 urn Value 0, "goap"5, , "brush" "comb3, "brush"7 0, "soap"5, comb: 3, "brush": 7Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started