def get_cost_per_item(shoplist): """ Args: shoplist (dict): Shopping list Returns: dict: Fruit total cost per item keyed by fruits Examples: >>> get_cost_per_item({'Black Plum': 8, 'Bosc Pear': 4}) {'Bosc Pear': 7.96, 'Black Plum': 23.92} """ return {key: numfruits * FRUIT[key] for key, numfruits in shoplist.iteritems() if key in FRUIT.keys()}
def get_cost_per_item(shoplist): """ a fucion get cost of items args: shoplist(dict): a dictionary called shoplist which keys are item name as found in FRUIT and the value should be an integer indicating the number of units to purchase. return: None example: >>> print shoplist {'Lime': 12, 'Red Pear': 4, 'Peach': 24, 'Beet': 1} >>> get_cost_per_item({'Lime': 12, 'Red Pear': 4, 'Peach': 24, 'Beet': 1}) {'Lime': 7.08, 'Peach': 95.76, 'Red Pear': 9.96} """ results = {keys: shoplist[keys] * FRUIT[keys] for keys in shoplist.keys() if keys in FRUIT.keys()} return results
def get_cost_per_item(shoplist): """Returns Sum of individual items in a shopping list. Args: Dictionary list (DICT). Returns: Number: Returns string from FRUIT.data and its sum. Examples: >>> get_cost_per_item({'Lime': 12, 'Red Pear': 4, 'Peach': 24, 'Beet': 1}) {'Lime': 7.08, 'Peach': 95.76, 'Red Pear': 9.96} """ T = 0 S = {} for k, v in shoplist.iteritems(): if k in FRUIT.keys(): T = v * FRUIT[k] S.update({k:T}) return S