10.8 Keeping track of the Produce. What's wrong with my code?


#1

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

Error code:
File "python", line 15, in
ValueError: incomplete format


#2

@littleamie8,

You have to use the fully formatted statement
like

 print key
 print "price: %f" % prices[key]
 print "price: %s" % prices[key]
 print "stock: %s" % stock[key]
 print("stock: {0} ".format(stock[key]))
 print("key: {0} stock: {1} {c1}".format(key,stock[key],c1="comment"))

google search
== the Book ==
[your question] site:python.org

== discussions / opinions ==
python [your question] site:python.org