Making a Purchase


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

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

#2

Please show us your code with indents. Paste your code, select it and press Ctrl + Shift + C or even better place it between three backticks/backquotes before your code and three backticks/backquotes after your code.
Without proper indents I can't say what may be wrong.


#3

whoops! Sorry about that, I went and fixed it, thanks


#4

Ok, try with changing indentation of return to the same level as for has. This seems to be the only issue.


#5

omg X_x it's always one little thing, isn't it?

Thanks a bunch!