FAQ: Using Dictionaries - Get an Invalid Key

Community%20FAQs%20on%20Codecademy%20Exercises

This community-built FAQ covers the “Get an Invalid Key” 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 Get an Invalid Key

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!

A post was split to a new topic: Misleading again

Why am I getting an error with this, please ? :pray:

Please post a link to the lesson page.

From the message given at the bottom, I assume it wants:

if "energy" in zodiac_elements:
  print(zodiac_elements["energy"])

In a more general case, you’d do:

if key_to_check in zodiac_elements:
  print(zodiac_elements[key_to_check])
1 Like

https://www.codecademy.com/courses/learn-python-3/lessons/using-dictionaries/exercises/get-invalid-key

Thanks again, sry about that…

I’ve reset the lesson and done as Jan above has suggested… Follow the instructions literally and don’t create any new variables.

I appreciate it very much :v:

1 Like

I was stuck on the Not a Zodiac element part, and it wouldn’t let me progress because I capitalised Element. That took me a while to notice :upside_down_face: