FAQ: Using Dictionaries - Review


#1

This community-built FAQ covers the “Review” exercise from the lesson “Using Dictionaries”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Review

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

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


#2
for key , values in spread.items():
  spread += tarot.pop(13)

I don’t know why I get KeyError even when the key is present. Can someone explain where I am going wrong?


#3

Iterate through the items in the spread dictionary and for each key: value pair …
I guess the word “pair” is confusing.

First you add the tarot.pop(KEY) command to the spread list:

spread[“past”] = tarot.pop(13)

if you think about it: tarot.pop(13) gets only triggered, by calling the value of its key = [“past”] .
spread = {key: value} or spread = {“past”: tarot.pop(13)}
(key) = “past”
(spread[key]) = Value = tarot.pop(13) = remove & returns Key + Value (13: “Death”) from tarot dictionary

in your case:

for key in spread:
      print(" Your " + (key) + " is the " + (spread[key]) + " card." )



hope that helps