FAQ: Learn Python: A Day at the Supermarket - Something of Value

This community-built FAQ covers the “Something of Value” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise Something of Value:

None of the above? Find out where to ask other questions here!

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

again, your interpreter is too simple.
the solution “total = total + prices[food] * stock[food]” is the same as

total += prices[ x ] * stock[ x ] <-- i have to place a space before and after the “x” otherwise it becomes a check mark!

but the interpreter rejects it with an error!

Why does this work:

total = total + prices[fruit] * stock[fruit]
print total
#the sum of prices multiplied by the stock and returns 117.0

but this does not work and returns 0

total2 = prices[fruit] * stock[fruit]
Print total + total2
#new variable total2 should equal 117.0
#new variable total2 + total should equal 117.0

1 Like

Why doesn’t my code work?
Screen Shot 2020-06-15 at 1.32.44 PM

Your code doesn’t work because food is not a key. You should have switch the ‘food’ with key because its the key of the price and stock.
then after that you print the variable