10.8 Keeping track of the Produce


#1

Continuing the discussion from 10.8 Keeping track of the Produce.What's wrong with my code prints for orange?:

I have been facing the error msg even though I have written an appropriate code.
Could any one sought out where the problem lies.

Thanks in advance.Hope you people get the right solution.


#2

I've checked your code and compared it to mine, actually the same (I just have a different name for key) and it should actually work

Try to reload the page and then look if it works


#3

Hello, @digveejay!
Sometimes the compiler doesn't really get what you wrote, so'll think you've done something wrong when you didn't.
Try refreshing the page and executing again or change browsers.

Best regards,
g4be


#4

I have the same problem.
Tried to refresh the page few times by F5 and by Ctrl+F5.
No way


#5

Either try using another browser or just printing the values without the phrases "Prices" and "Stocks".


#6

@frozentofu
I have tried in all format possible to get the solution but could not get a solution it would be better if you could post the solution after you pass this level.


#7

hi @g4be

We could not sort the problem by removing the phrases mentioned by you have you tried and get the output printed without any error msg as I have tried by removing the phrases and failed to get the resut


#8

Would you mind posting the code so I can give a look?
Maybe it's something there that we didn't see.


#9

It's not the code which is wrong, but just the site itself doesn't refresh properly. I had this issue a few times too. Resetted the code and tried it the next day. Just try different things and it should work out somehow ^^


#10

Oh well, if it's the site itself, try it later, it should work.
Also, make sure to follow the instructions such as messages to be printed because even a missing dot at a message can/will cause an error on your program.
Been there, done that.


#11

Hi,

Could you change "print "Prices:~~~" to "print "Price:~~~"?

Prices seems typo.

Hope to help your problem.


#12

Hi @frozentofu, @cs_yu

The code which has been written think is write I have also checked with many changes in the code to get to the solution. To confirm again I have performed with the changes insisted by you hope some one could get the correct solution.

We can post the code here also no issues it would be helpful to all who got stuck.
Kindly only past the code for whom the output is correct kindly dont past the same code as it clumsy for other to get the correct content for chat.

Thanks .


#13

Found the solution: change your dictionary to price not prices and all other instances this seems to be causing the problem. Guess it wants to see price and not prices


#14

Did you get the result with out any error msg as the dictionary are given initially and I hope no changes should be made to them.


#15

change dictionary to price and all other instances seems to solve the solution!!!! guess they told you to create the wrong dictionary, look at the example above your instructions that's what made me change mine as my output was different ie the dictionary call


#16

could u post the code as it would resolve this doubt to all


#17

print "price: %s" % prices[key]
--> "price without s :slightly_smiling:


#18

price = {
"banana" : 4,
"apple" : 2,
"orange" : 1.5,
"pear" : 3,
}
stock = {
"banana" : 6,
"apple" : 0,
"orange" : 32,
"pear" : 15,
}

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


#19

it did'nt tab all of this as i copy n pasted just change whats different to yours and should work


#20
1. Loop through each key in prices. <-

As far as I know, you should leave the dictionary as "prices", like in the instructions :confused: