Learn
Now you need your compute_bill
function to take the stock/inventory of a particular item into account when computing the cost.
Ultimately, if an item isn’t in stock, then it shouldn’t be included in the total. You can’t buy or sell what you don’t have!
Instructions
1.
Make the following changes to your compute_bill
function:
While you loop through each item of food
, only add the price of the item to total
if
the item’s stock
count is greater than zero.
if
the item is in stock and after you add the price to the total
, subtract one from the item’s stock
count.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.