12-Stocking out


#1

shopping_list = ["banana", "orange", "apple"]

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}

prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}

Write your code below! total = 0

for item in stock:
number_purchased = min(stock[item]) # this is line 19
total += prices[item] * number_purchased
stock[item] -= number_purchased

It returns Traceback (most recent call last):

File "python", line 19, in
TypeError: 'int' object is not iterable.Somebody help me with the correct code.


#2

This a dupe. Question was answered in this post.