Feedback for Delete a Key

The wording on this question was incredibly confusing to me.

In case someone reading this is stuck, I would have written the question like this:

You are designing the video game Big Rock Adventure. We have provided a dictionary of items that are in the player’s inventory which add points to their health meter. In one line, add the corresponding value of the key ‘stamina grains’ to the existing variable health_points and remove the ‘stamina grains’ key:value pair from the dictionary. Write the code so that if the “stamina grains” key does not exist, 0 will be added to health_points .

7 Likes

I think it wasn’t clear from this question that the variable health_points needed to be ADDED to as opposed to simply updated.

I initially tried:

health_points = available_items.pop(“stamina sandwich”, 0)

When in fact it should have been:

health points += available_items.pop(“stamina sandwich”, 0)

I think the feedback that codecademy provides once you get something wrong but close could be improved…

1 Like

wow, this was more confusing than some of previous lessons. How do you come up with those numbers esp. 65. I thought if there was not a ‘mystic bread’ it would = 0. How did the number 65 come up? I have getting solutions instead of trying to answer on my own because I get stuck and can’t figure out some of the solutions. Can someone help?