Can't find the answer


#1

I've had issues with the code for the bill calculation so i've been searching through the forum to see if i can find the answer. Alas, all of the threads that I have read through and edits that I've made to my code nothing is working (the bug just changes).

My code is as follows:

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 prices:
total += prices[key] *stock[key
return total

The error flavour of the minute is:

File "python", line 23
return total
^
SyntaxError: invalid syntax

Please help.....


#2

It is indented correctly, and was here until i pressed enter.... but the indentation is correct.


#3

If it is indented correctly, then how come we can't see that?


#4
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 key in prices:
        total += prices[key] *stock[key
    return total

#6

See how quickly the solution falls out when other concerns are cast aside?


#8

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