Keeping Track of the Produce


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/3?curriculum_id=4f89dab3d788890003000096

<In what way does your code behave incorrectly? Include ALL error messages.>
Error:
Something went wrong :frowning:
Click Close to try again or refresh the page.

<What do you expect to happen instead?>
No error

```python

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]

<do not remove the three backticks above>

#2

Hello @brycewilkerson. :slight_smile: Look at this line:

Check your spelling. :slight_smile: This should be your output:

apple
price: 2
stock: 0

#3

Now receiving this error: "Traceback (most recent call last):
File “python/cli_runner.py”, line 152, in "


#4

Can you post your new code? Thanks :slight_smile:


#5

Any idea where the"line 152" comes from? My code only has 18 lines

Prices dictionary

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

Stock/Inventory dictionary

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

for key in prices:
print key
print “price: %s” % prices[key]
print “stock: %s” % stock[key]


#6

Look at the quotation marks in all of your code. (I’ll snip out a part for you to look at:)

Yours (“ ”) compared to my quotation marks (" "):

"banana"

There’s a difference. I copied your code and tested it. Yep, it’s gotta be that. Are you using any special keys, or some sort of CAPS LOCK/Shift? If so, fix that/turn it off and see what happens :slight_smile:


#7

I went back to the previous lesson and re-submitted. After I moved to the current module, the code submitted just fine.
Thanks for your help


#8

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 “price:%s”%prices[key]
print “stock:%s”%stock[key]

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

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

what’s wrong with my code


#9

You need to have a space between your string and the % dict[key]. (that’s an example)

Next time, instead of interrupting someone’s topic, you can create a new one like it’s stated in the Guidelines. Thank you. :slight_smile:


#10

thank you very much
i just miss two spaces


#11

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