Stocking out


def compute_bill(food):
total = 0
for food in food:
if stock[key] > 0:
total += prices[key]
stock[key] = stock[key] - 1
return total

i think i missed something on the code it seems i didn't define the key...

#12 stocking out

if you have a for loop:

aList = [1,2,3,4,5]
for x in aList:
   print x

in the above code, x is the iterator.

looking at the code, you seem to wanting to use key as iterator, yet if you look at the for loop, your iterator is food, maybe change the iterator? the iterator having the same name as the list is a bad idea, maybe rename the iterator to key?


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