Error Message on "apple" only


I was wondering if someone else is getting the same error as I do. It keeps saying :
**"Oops, try again. compute_bill(['apple']_ returned None,
did you remember to return the result?"**

My code looked like this:

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 item in prices:
        total += prices[item]
    print total



you want to loop for item in food and not prices.


I've been switching that part up and it still has the same error:

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


Okay, return and not print the for loop here:

Please, retain the last code edit.


Lol thanks! This worked


You're welcome.

Have fun coding! :slight_smile:

[Yeah! You should learn to return your loop output before considering print.]


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