I can't keep track of my produce in order


#1



Hello.
I am stuck on lesson 8 Keeping track of the produce.
You can see my code down below but this is my error message:
Oops, try again. Check what your code prints for orange. It doesn't look quite right!
In the box where it shows my output looks alright but the order is wrong. The Orange comes first then pear the banana then apple.
I do have the price and stock sorted but I am guessing the problem is the order:
banana should come first then apple then orange then pear.
So I'm not sure.

That is my code:

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


#2

Dictionaries are unordered, there is no order to adhere to.

What you are printing doesn't match the format described in the instructions, compare them.


#3

I also for got to add this. This is my output box. Everything is shown except for one line under everything that says none


#4

Ok thanks for your help.


#5

I did compare them and I did exactly what it said I have triple-checked it. Save the words I needed to switch out.


#6

It didn't work. I still need help.


#7

There's an example in the instructions. Compare it character by character with what you print.
It should not be possible to tell any difference, it should be an exact match.

apple
price: 2
stock: 0

That's 24 characters, including line terminations, sufficiently short to just eyeball it.

There are also tools where you can copy each one and compare them, I'm sure there are a few online variations if you search for "online diff tool"


#8

It's one character in your print statement at the bottom. Match the output EXACTLY as the instructions request.


#9

hi, i know what's the problem, it's should
print "price: %s" % prices[key]


#10

Thank you so much.
I was also stuck at this lesson.
Your comment helped:slight_smile: