A Day at the Supermarket( problem with orange )


#1



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


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

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

ciclo=0
x=["banana","apple","orange","pear"]

for y in x:
print "product : " + x[ciclo]
p=( prices[x[ciclo]])
print "prices : "+ str(p)
print "units : " + str(stock[x[ciclo]])
ciclo=ciclo+1

product : banana
prices : 4
units : 6
product : apple
prices : 2
units : 0
product : orange
prices : 1.5
units : 32
product : pear
prices : 3
units : 15
None

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


i think the problem is in the float number in the price of orange.
but i think the code run ok , because print exact information product name = orange , price=1.5,and units 32 .
thank for your help


Replace this line with your code.


#2

i change the string in the code and run ok for the web site.

prices={
    "banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
    }
    
stock={
   "banana": 6,
"apple": 0,
"orange": 32,
"pear": 15, 
     }    
    
ciclo=0
x=["banana","apple","orange","pear"]  

for y in x:     
    print x[ciclo]
    p=( prices[x[ciclo]])
    print "price: "+ str(p)
    print "stock: "+ str(stock[x[ciclo]])
    ciclo=ciclo+1

#3

so, now it works? Or do you still have a question?


#4

now it work ok thank , in the second post i post changes in code


#5

i just wanted to make sure everything was ok and there where no more questions


#6

your super fast , great work


#7

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