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


#1

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
Steve


#2

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


#3

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


#4

All good now? No further questions?


#5

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


#6

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