8. Keeping track of the produce


I'm not sure what is wrong with this code, the error coming up is "Check what your code prints for orange. It doesn't look quite right!" When I look at what the code prints, it looks totally fine.

Also, what is the reason for the %s and % on the final two lines

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]


the output is case sensitive.

%s serves as a string placeholder for a variable


we encounter the same problem, make 'Price: %s' be 'price: %s' , it works, trust me!


It worked. Thanks
Seems a bit odd though


That fixed it. Thank you

How come it couldn't be

print 'Price: ' prices[key]


the exercise validation is case sensitive, and the output should be an exact match


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