Could you please help fix the following code in Python?
marinazhiv (0)

shopping_cart = ["celery", 4, 9, "beef", 15, 3, "eggs", 2, 12, "bread", 4, 1]
item = string()
for item, cost, qty in shopping_cart:
unit = cost/qty
unit = round (unit, 2)
print(item[0], "has a unit cost of $", unit)

You are viewing a single comment. View All
JoshDaBosh (77)

you forgot to group the ingredients together in shopping_cart like so:

shopping_cart = [["celery", 4, 9], ["beef", 15, 3], ["eggs", 2, 12], ["bread", 4, 1]]
ash15khng (504)

@JoshDaBosh You should use a dict for that.