It doesn't like my code but it works in Aptana


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/2/3?curriculum_id=4f89dab3d788890003000096#


I think it works correctly but it keeps on failing. I'm not sure if it's expecting me to use input or not.


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 foods in food:
        if stock[foods] >= 0:
            total = prices[foods] + total
            stock[foods] = stock[foods] - 1
    return total
foodlist = ["apple", "banana"]
x = compute_bill(foodlist)
print x


#2

This might be a case that because Codecademy's python course is still on Python 2 I believe and most other programs uses Python 3 that some changes in Python 3 are still counted wrong or incorrect in Python 2. Just a guess. If that is the case might have to reformat your code based on the lesson and Python 2 standards.


#3

Any suggestions on what I can suggest to get it to work? It won't let me get past the lesson.


#4

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