Making a Purchase question

#1

Making a Purchase
10 A Day in the Supermarket

In this exercise i got two answers correct, one with this code:

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

print compute_bill(food)``````

and the other with this code:

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

print compute_bill(stock)``````

I'm not seeing something obvious or just the exercise have two ways of being solved?.

Thanks for eyes ,brains and time to respond !

#2

Unless I am seeing incorrectly, there is no difference between the two blocks of code.

Could you please point out the differences.

#3

the argument at function call

#4

ohhhh lol I didn't notice it had scroll, so I didn't see the function calls

#5

one will calculate the cost for items in shopping_list, the other will calculate the cost for buying one item of each you have in stock

#7

thank you very much @steim94 !!! now i realize about that !

#8

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