Input required for checking out multiple amounts of an item


#1

https://www.codecademy.com/courses/learn-python/lessons/a-day-at-the-supermarket/exercises/lets-check-out?action=resume_content_item
shopping_list = [“banana”, “orange”, “apple”]
stock = {
“banana”: 6,
“apple”: 0,
“orange”: 32,
“pear”: 15
}

prices = {
“banana”: 4,
“apple”: 2,
“orange”: 1.5,
“pear”: 3
}
compute_bill(food):
total = 0
for item in food:
if stock[item]>0:
total = total + prices[item]
stock[item] = stock[item] - 1
return total

print(compute_bill(shopping_list))

When I print the shopping_list, the output I get is 5.5 in which an orange and a banana is checked out. So what if I want to purchase more amount of oranges or bananas? how should I change the list?


#2

If I remember correctly, that is covered in a later lesson. Not sure, though. Please post a link to the exercise. Thanks.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.