I think everything is printing out right but it tells me otherwise


#1


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

I expected it to run fine which in my eyes it did

stock = { "bananas" : 6, "apples" : 0,  "pears" : 15,"oranges" : 32  }
for fruit in prices:
    print fruit
    print "price : %s" % prices[fruit]
    print "stock : %s" % stock[fruit]


and this is what it prints:
pears
price : 3
stock : 15
bananas
price : 4
stock : 6
oranges
price : 1.5
stock : 32
apples
price : 2
stock : 0
None

But still I'm left with the error that something about the way its printed looks funny. Can anyone help me?


#2

you have a space between price and the colon, you need it to look like price: (no space)
same for stock's print line.
hope this helps! :slight_smile:


#4

Thank you! this fixed it :slight_smile:


#5

glad to help!


#6

Im in the same situation. Any help would be much appreciated.

prices = {"banana": 4, "apple": 2, "orange": 1.5, "pear": 3}

stock = {"banana": 6, "apple": 0, "orange": 32, "pear": 15}

for key in stock:
print key
print "prices: %s" % prices[key]
print "stock: %s" % stock[key]

output:
orange
prices: 1.5
stock: 32
pear
prices: 3
stock: 15
banana
prices: 4
stock: 6
apple
prices: 2
stock: 0
None


#7

Sorry to bother. Its because I used prices which is the same as my dictionary and I guess i needed to use price. price it is.


#8

Hey
I figured it out on my own, but I want to understand WHY it is requiring the ":" without the space...
Is it WRONG syntax or just for this AUTOMATED checker of the app?

I initially used print "In Stock: %s" and it failed too...

THANX


#9

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