Why only orange would lead to an error?


#1

having the same issue. can't understand why only orange would lead to an error if they are all formatted the same

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= " + str(key)
print "prices: %s " %prices[key]
print "stock: %r" %stock[key]

**a note that the code is interpreted without error in the subsequent exercise


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

No verbosity, and key is already a string so no need to cast it.

print key

The SCT has a limited number error messages and this one is the most common.


#3

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