shopping_list = <"banana", "orange", "apple">stock = "banana": 6, "apple": 0, "orange": 32, "pear": 15prices = "banana": 4, "apple": 2, "orange": 1.5, "pear": 3# create your password below!def compute_bill(food): total = 0 because that item_food in food: because that item_stock in stock: if item_stock == item_food: if stock > 0: stock = stock - 1 total = complete + prices return totalfood = <'banana', 'apple', 'orange', 'pear'>total = compute_bill(shopping_list)print totalI am almost sure the it must work. It returns total=5.5. One banana price + one orange cost and also NO apple cost due to the fact that we execute not have apples. But rwandachamber.org screen tells me that my code is not correct

BlockquoteOops, shot again. Your total is as well low. Make sure you are gaining every item in the list.

Any ideas?




You are watching: Codecademy a day at the supermarket

Answer 52d81e97282ae39daf0002d0


5 votes

Permalink


Well, the code works if you remove the las three lines… I should say that this isn’t the simplest answer however it works too. The one i’ve made is so much simple:

> def compute_bill(food):> complete = 0> for i in food:> if stock > 0:> full = full + prices> stock = stock - 1> return total
points

Submitted through Miquel Roy Sunyer
over 7 years

4 comments


Алексей Ананьин over 7 years
SOLVED


*
Connor Divelbess end 7 years

I wouldn’t recommend that you usage != in this case, together it would certainly still be True if over there were negative apples.

if stock >= 1: would job-related better


Miquel Roy Sunyer over 7 years

This is true. Thanks!


*
ADHAM RATABA end 6 years

Thanks! I spent three job trying to fix this!


Answer 52d820d17c82ca5c5b000411


2 votes

Permalink


it really works without last three lines :) give thanks to you.

And YES. Your password is mush simpler


points

Submitted by Алексей Ананьин
over 7 years

1 comments


*
makifv about 7 years

dude the picasso’s hardcore. The code listed below is much asier. Thx ny way.


Answer 5481ed639113cbe1920012a9


2 votes

Permalink


none that ur codes work


points
*

Submitted by fhs10668
almost 7 years

Answer 54099bd09c4e9d7ce40030a7


1 vote

Permalink


def compute_bill(food): full = 0 for item in food: if stock > 0: full = full + prices stock = stock - 1 print full return total


points
*

Submitted through eeaykut
about 7 years

Answer 54bf9130e39efe4120000c9b


0 votes

Permalink


I supplied the logic as given below but still i am no able to overcome the stage. It showing correct an outcome b ns am not able to figure around any other trouble !!

shopping_list = <‘orange’,’pear’,’banana’,’banana’,’banana’,’banana’,’banana’>

stock = “banana”: 6, “apple”: 0, “orange”: 32, “pear”: 15

prices = “banana”: 4, “apple”: 2, “orange”: 1.5, “pear”: 3

new=stock.copy()

Write your code below!

def compute_bill(food): full =0

for ns in food: # print new if(new >0): full = full + prices new = new-1return totalprint compute_bill(shopping_list)


points
*

Submitted through Mukesh Goyal
over 6 years

Answer 54bf91499376766a54000baa


0 votes

Permalink


I used the logic together given listed below but still i am no able to overcome the stage. It showing correct result b i am not able to figure around any other problem !!

shopping_list = <‘orange’,’pear’,’banana’,’banana’,’banana’,’banana’,’banana’>

stock = “banana”: 6, “apple”: 0, “orange”: 32, “pear”: 15

prices = “banana”: 4, “apple”: 2, “orange”: 1.5, “pear”: 3

new=stock.copy()

Write your password below!

def compute_bill(food): full =0

for i in food: # print new if(new >0): complete = total + prices new = new-1return totalprint compute_bill(shopping_list)


points
Submitted through Mukesh Goyal
over 6 years

Company


Resources


Support


Community


Individual Plans


Enterprise Plans


Mobile


Support


Course Catalog


Languages


Subjects




See more: (Aka American Guinea Pig: The Song Of Solomon (Review), American Guinea Pig: The Song Of Solomon (Review)

Languages