Question: IN PYTHON 3 LANGUAGE write a unique_supplier function takes a dict argument in the form illustrated above, each key in the dict is a str
IN PYTHON 3 LANGUAGE write a unique_supplier function takes a dict argument in the form illustrated above, each key in the dict is a str (the warehouse) whose associated value is another dict: this inner dict associates a str (the product) with an int (the inventory) and returns a dictionary (dict or defaultdict) whose keys are str (the warehouse) and whose associated value is a set of all the products that are stocked only from that warehouse (even if the inventory is 0).
Calling this function with the db dictionary shown on the top of page 2 unique_supplier( db ) returns a dictionary whose contents are:
DESIRED OUTPUT: {'Irvine': {'brush'}, 'Newport': {'stapler'}, 'Tustin': {'pencil', 'keychain'}} This result shows that a brush is stocked only in Irvine, a stapler is stocked only in Newport (even though its inventory is 0),and a pencil and keychain is stocked only in Tustin.
Information needed: For example, the db1.txt file contains the lines brush:Irvine:3 comb:Irvine:2:Newport:1 wallet:Irvine:2:Tustin:3 stapler:Newport:0 keychain:Tustin:3 pencil:Tustin:4
db: {'Irvine': {'brush': 3, 'comb': 2, 'wallet': 2}, 'Newport': {'comb': 1, 'stapler': 0}, 'Tustin' : {'keychain': 3, 'pencil': 4, 'wallet': 3}}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
