Keeping Track of Produce (Help!)


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/3?curriculum_id=4f89dab3d788890003000096


You should have exactly three print statements! (Make sure there are no occurrences of 'print' in any comment or string!)


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


#2

If you only print the price and how many are in stock, how would you know later what specific item it is?


#3

Are you doing a course in Python?


#4

Yeah I'm currently doing a course , I just don't know what I did wrong with this:

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


#5

You need a third print statement...


#6

Well if I can I will try to get to that lesson, I passed it except I deleted my account a few days ago and remade it so it might take me some time. I'll try my best


#7

Can you tell me what specific lesson in which section you're in, if that doesn't divert you from what you're doing?


#8

If you wouldn't mind explaining something about your code from your other question why do you have colons?


#9

What other print statement I should use?


#10

Right now you have identified the price and how many there are,what would you print to identify the item itself?


#11

I don't know yet, what does s stand for?


#12

How about this:

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"
print "stock: %s"


#13

%s represrests a placeholder for string formatting. The correct syntax for this is:

print "prices: %s" % list[key]

#14

sorry that I'm asking you questions, since I'm supposed to be helping. Hope that's ok.


#15


Is this a result that would work for the groceries, I think you already understood what to do, but I wanted to figure it and so hers is my result.


#16

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