Zoo Animals - Assigning a new value to a key


#1

https://www.codecademy.com/courses/learn-python/lessons/python-lists-and-dictionaries/exercises/changing-your-mind

I’m trying to move the Rockhopper Penguin to a new exhibit, but I’m getting the following error:

NameError: name ‘Iceberg_Land’ is not defined

Zoo%20Animals

I tried putting single ‘quotes’ around the value ‘Iceberg Land’ but I’m still getting the same error. Any insight?


#2

Did you try double quotes (not that it should matter)? The string definitely needs quotes.


#3

I tried double quotes, I’m not sure why that would change things, but now I’m getting the error: ‘dict_name’ is not defined.

Isn’t that command already defined in python? Do I need to refer to the zoo_animals dictionary in that line somehow? :thinking:


#4

zoo_animals is the dict_name (pseudo_variable) in this case.

zoo_animals['Rockhopper Penguin'] = 'Iceberg Land'
     ^              ^                     ^
     |              |                     |
 dict_name         key                  value

#5

:man_facepalming: that makes total sense, thank you Roy. I appreciate you explaining the logic and not just giving an answer, you’ve been a huge help to me.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.