Need help please.There is an error,but where?I have tried a variety of methods


#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!

def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total = total + prices[item]
stock[item] = stock[item] - 1
print total
return total

bill_total = compute_bill(shopping_list)
print bill_total

<img src="//codecademy-discourse.s3.amazonaws.com/original/5X/7/5/c/8/75c8512b69d8bd75cf8d1d27ffa4d91f09ad42ae.png" width="363" height="394">

#2

Please post your preformatted code,


#3

Umm , may I ask you a stupid question, how can I submit those preformatted codes?


#4

Write your code below!

def compute_bill(food):
total = 0
for x in food:
total += prices[x]
return total

that works


#5

Please check out this post,


#6

How are you helping the user by giving him your code? People come here for help, not for unexplained answers. :slight_smile:


#7

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