When I click [Save & Submit Code], the validator gives me an error message. I checked my code many times and finally started writing in print lines to see what my code was doing at certain steps. The last one displays the value the lesson was trying to get me to. The error message from the validator gives erroneous numbers.
Error message example:
Oops, try again. calling compute_bill with a list containing 2 pears, 1 orange and 8 bananas resulted in 39.5 instead of the correct 31.5
These are my results:
The last number is the final, and correct, total: 5.5. Every time I click on the [Save & Submit Code] it gives me different numbers. For example:
Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear, 1 orange and 9 bananas resulted in 40.5 instead of the correct 28.5
Oops, try again. calling compute_bill with a list containing 2 apples, 3 pears, 3 oranges and 9 bananas resulted in 49.5 instead of the correct 37.5
Oops, try again. calling compute_bill with a list containing 2 apples, 2 pears, 1 orange and 9 bananas resulted in 43.5 instead of the correct 31.5
Between all of the attempts at saving the code that generated each of the messages above, I made no changes to the code and my results remain the same.
def compute_bill(food): total = 0 for item in food: print item print stock[item] print prices[item] if stock[item] > 0: total += prices[item] stock[item] -= 1 print total return total compute_bill(shopping_list)
I skipped so I could move on and the next page was the section wrap up. The instructions: "Click Save & Submit Code to finish this course." Did that and no error.