Answer:
def add_prices(basket):
total = 0
for items in basket.values():
total += items
return round(total, 2)
groceries = {"bananas": 1.56, "apples": 2.50, "oranges": 0.99,"bread": 4.59, "coffee": 6.99, "milk": 3.39, "eggs": 2.98, "cheese":5.44}
print(add_prices(groceries)) # Should print 28.44
Explanation:
The python dictionary is a data structure that stores items of data as a key-value pair. The keys and values can be listed separately using the keys() and values() built-in function.
The program above uses a for loop statement to iterate over the values of the groceries dictionary to return the total sum of the values.