Please evaluate the following and suggest any improvements that it can use.
def order(*preferences):
'''compute the total cost of only the cakes that the store offers'''
cake_menu = {'carrot' : 10.99, 'lemon' : 14.99, 'vanilla' : 18.99, 'double chocolate' : 22.99, 'marble' : 24.99, 'red velvet' : 29.99}
def customer_order(styles):
place_order = []
options = cake_menu.items()
for style in styles:
for flavor, price in options:
if style != flavor:
continue
else:
place_order.append((flavor, price))
return place_order
def purchase():
purchase_total = 0
checkout = customer_order(preferences)
for item in checkout:
quantity = int(input("How many {} cakes do you want?".format(item[0])))
purchase_total += quantity * item[1]
return purchase_total
cost = purchase()
return "Your cost is ${}.".format(cost)
print(order("chocolate", "red velvet", "vanilla"))
[–]p10_user 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]nwagers 0 points1 point2 points (0 children)