Question: Language: Python Function name: total_cost Parameters: list, boolean Return value : list Description: After you come back from vacation, you want to figure out how
Language: Python
Function name: total_cost
Parameters: list, boolean
Return value : list
Description: After you come back from vacation, you want to figure out how much you spent per item. Write a function that takes in a list of strings in the format "item $0.0" and a boolean. If the boolean is True, you want to return a list containing the float of the total cost of all the items in the list. If the boolean is False, you want to return a list of lists, where each list contains the item name and the total price for that item. If an item appears more than once in your list, you should add the prices together. If an empty list is passed in, return an empty list.

total_cost(I,True) (0.0/4.0) Test Failed: 0 - total_cost(muji pens $18.32, 'muji pens $18.32, 'muji pens $18.32], True) (0.0/4.0) Test Failed: could not convert string to float: ens total_cost(l'muji pens $18.32', 'muji pens $18.32, 'muji pens $18.32], False) (0.0/4.0) Test Failed: could not convert string to float: 'ens total cost'ice cream $3.0; pizza $4.0, 'gelato $3.0, 'pizza $32.02, 'gelato $3.23],True) (0.0/4.0) Test Failed: could not convert string to float: 'ream total_cost(Tice cream $3.0, 'pizza $4.0, 'gelato $3.0, 'pizza $32.02, 'gelato $3.23],False) (0.0/4.0) Test Failed: could not convert string to float: 'ream
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
