10/13 help


#1

this is the code i put however it says that when "apples" is applied, it gets 0 instead of two. i'm not sure what i've done wrong so any help is much appreciated.

this is my written code, i've excluded what was provided:

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


#2

in 10/13 all you have to do is
"First, make a list called groceries with the values "banana","orange", and "apple"."
So just do this.

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

or did you put the wrong exersize number in the title?


#3

Try this. I have indicated what changed

def compute_bill(food):
    total = 0 
    for item in food:
        if stock[item] != 0: #just changed this
            total += prices[item]
            stock[item] = stock[item] - 1
    return total

In the future it will be a good idea to format your code to make it easier to test.
You can push ctrl + k to format your code(after you select it) or that </> in the tools pane


10.11 Printing total of items in prices dictionary
#4

All i did was delete the print function at the end and change the 'stock[item] function to -= 1, and it works for me

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

#5

thank you! and yes i did put the wrong lesson number, i apologize


#6

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

Here, indent this and it'll work.