Python - A day at the Market


#1

Hi!
I can't go to the next step.
please Help!
**Visit each of the keys in prices .
As in the above example , display the key with your pricing information and actions. Display the answer in the following format :
apple
price : 2
Stock: 0
**

error message: Oops, try again. Check your code displays to orange . That does not seem right !

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

This part

print "prices: %s"...

You should remove the s frome prices


#3

not really! =/
i just try this:

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

**Traceback (most recent call last):
File "python", line 15, in
TypeError: not all arguments converted during string formatting**


#4

@wizmarco
i try this too:

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

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


#5

Sorry if I wasn't Clear not frome %s but frome prices

print "prices:

Should be like that

print "price: %s" ...

#6

just try this too:

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

and: ERROR=error message: Oops, try again. Check your code displays to orange . That does not seem right !


#7

It should be like that

print "price: %s" %  prices[key]
print "stock: %s" % stock[key]

#8

that i try before! =('


#9

this bit:

print "prices: ",

of this line:

print "prices: ", prices[key]

should be:

print "price: ",

price here is without s (you had prices, with s), sometimes the things printed should be an exact match! Hope this helps


#10

@stetim94 and @wizmarco
it was i try before:
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]


#11

and that too:

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


#12

you still have priceS instead instead of price in this bit:

print "prices: %s", #priceSSSS

it should be:

print "price: %s", #price without SSS

i don't know how to make it more obvious, but your print is NOT an exact match


#13

Alright!
It works! sorry for my distraction!

Thanks!