Learn
Now that you have all of your product info, you should print out all of your inventory information.
once = {'a': 1, 'b': 2} twice = {'a': 2, 'b': 4} for key in once: print "Once: %s" % once[key] print "Twice: %s" % twice[key]
- In the above example, we create two dictionaries,
once
andtwice
, that have the same keys. - Because we know that they have the same keys, we can loop through one dictionary and
print
values from bothonce
andtwice
.
Instructions
1.
Loop through each key in prices
.
Like the example above, for each key, print out the key along with its price and stock information.
Print the answer in EXACTLY the following format:
apple price: 2 stock: 0
Like the example above, because you know that the prices
and stock
dictionary have the same keys, you can access the stock
dictionary while you are looping through prices
.
When you’re printing, make sure to use the syntax from the example above, with %s
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.