Zoo Animals - Assigning a new value to a key



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


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


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


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:


zoo_animals is the dict_name (pseudo_variable) in this case.

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


: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.


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