8. Keeping track of produce


#1

What’s wrong in code below? Output is as expected

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 "price: %s " % prices[key]
print “stock: %s” % stock[key]

OutPut:
orange
price: 1.5
stock: 32
pear
price: 3
stock: 15
banana
price: 4
stock: 6
apple
price: 2
stock: 0


#2

you have a space after %s (which shouldn’t be), that causes the error


#3

ThankYou, that helped!


#4