Keeping track of the produce


#1



Keeping track of the produce


Oops, try again. Check what your code prints for orange. It doesn't look quite right!


apple
price= 2
stock=2
(was what i was expecting)


price = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
    }
stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
    }
for key in prices:
    print "apple"
    print "prices: %s" % price["apple"]
    print "stock: %s" % stock["apple"]


#2

all I get is:
apple
prices: 2
stock: 0
apple
prices: 2
stock: 0
apple
prices: 2
stock: 0
apple
prices: 2
stock: 0
None


#3

desired output:

apple
price= 2
stock=2

your output:

apple
prices= 2
stock=2

see the difference? price vs prices


#4

it still posts:
apple
price: 2
stock: 0
apple
price: 2
stock: 0
apple
price: 2
stock: 0
apple
price: 2
stock: 0
None
just without the "s"


#5

NVM i got it but thanks anyway.


#6

yes, it will always print apple. not so nice, it should print all products. that is what the for loop is for, key will hold all products in turn, so maybe you should use key instead of "apple"


#7

i just thought it wanted me to only print apples.


#8

nope, step 1 and 2 of the instructions combined clearly indicate each key in prices should be printed along with the stock and price information


#9

2 posts were split to a new topic: Keeping trace of product


#10

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