Please why is not the same? (learning Python chap. 5/9)


Please there is someone could explain me why is not the same?
in learning python chapter 5/9 (something to value)

my code is

total = 0
  for key in prices:
    a = prices[key1]*stock[key1]
    print a
    total = total + a 
print total

the solution is

total = 0
for food in prices:
  print prices[food] * stock[food]
  total = total + prices[food] * stock[food]
print total

Thanks a lot


why does this line:

  for key in prices:

have indent (spaces/tabs)?

key1 which you use here:

a = prices[key1]*stock[key1]

isn’t defined anywhere


ahahah my gosh!!! thanks man…I was sleeping
thanks a lot


All good now? No further questions?


yes… no further questions
…for now… :slight_smile:


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