Keeping track of the produce


#1



PLEASE HELP !!!


#2

line 5, you have: print "prices %s" ....

however, this should be price, take a look at step 2 from the instructions, it shows the output should be price, not prices


#3

Is that because having "prices %s" will attempt to print the prices dictionary? I was stuck for a bit and this helped me but I need to understand why I was incorrect


#4

no, prices is inside the string, it will simple print prices, no attempt to access the prices dictionary. But the output should be an exact match, and as you can see in step 2 of the instructions, it should be price, not prices


#5

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 "price: %s, stock: %s" % ( prices[key], stock[key])

Can you please show me where I'm wrong here?


#6

There is no problem with the indentation. SO if there is anything else , do tell me.


#7

if you want to join a string and a variable, you need a + in between:

print key + "rest of your string"

That is the syntax error in your code, the other problem you have is that your output doesn't look like anything the exercise wants from you, the output should be on different lines


#8

Thanks for the input


#9

I can't seem to find the problem.Here 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 "prices: %s" % prices[key]
    print "stock: %s" % stock[key]

#10

How to say this nicely? If you decide to already add your question to a existing topic rather then a new topic (which is in the guidelines), then at least take some time to read the answers in a topic.

Since your question is exactly the same:

except for the small detail, that in your case it is not line 5. Seems you also forgot to print the product name (key), take a look at what the output should be:

Your code doesn't print the key (apple, banana and so on)


#12

jus show the value not key


#13

def fizz_count(x):
count = 0
for item in x:
if item == "fizz":
count = count + 1
return count

lost = ["fizz","cat","fizz","buzz","fizz"]
small = fizz_count(lost)
print small

that is the correct code....


#14

def fizz_count(x):
count = 0
for item in x:
if item == "fizz":
count = count + 1
return count

lost = ["fizz","cat","fizz","buzz","fizz"]
small = fizz_count(lost)
print small

that is the correct code