Question: 2. Write: A function called combine lists that takes two parameters, k and v, both lists. An item at index i in k is a
2. Write: A function called combine lists that takes two parameters, k and v, both lists. An item at index i in k is a string, the name of a person. An item at that same index i in v is a string, an tem that person owns The lists k and v are of equal length. combine lists should return a dictionary, where the keys are the names of people in k, and the values are lists of the items that person owns. For example: 1 peeps# ['Trevor', 'Joey', 'Joey', 'Trevor', 'Joey'] 2 stuff['Pencil', 'Notebook', 'Laptop', 'Speakers', 'Calculator' dcombine lists (peeps, stuff) 4 print (d) should output: 1 'Trevor' ['Pencil', Speakers', 'Joey' ['Notebook''Laptop' Calculator']) Write a function who that takes a two parameters, ledger, a dictionary in the return format of combine_lists, and item, a string. who should return a list of all of the people who own that item. For example: 3. 1d t'Joe': ['Soda', 'Candy', "Alex 2 print (who(d, 'Soda')) 3 print (who(d, 'Candy")) 4 print (who(d, 'Chips)) 'Soda', 'Pretzels
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
