Python Lists and Dictionaries: Changing your Mind


#1



Struggling with this task, not sure what to do. Can someone help me please? My code that I have used is below along with the error message.

https://www.codecademy.com/courses/python-beginner-en-pwmb1/2/3?curriculum_id=4f89dab3d788890003000096#


Traceback (most recent call last):
File "python", line 16, in
KeyError: 'Sloth'


Replace this line with your code. 
# key - animal_name : value - location 
zoo_animals = { 'Unicorn' : 'Cotton Candy House',
'Sloth' : 'Rainforest Exhibit',
'Bengal Tiger' : 'Jungle House',
'Atlantic Puffin' : 'Arctic Exhibit',
'Rockhopper Penguin' : 'Arctic Exhibit'}
# A dictionary (or list) declaration may break across multiple lines

# Removing the 'Unicorn' entry. (Unicorns are incredibly expensive.)
del zoo_animals['Unicorn']
del zoo_animals['Sloth']
del zoo_animals['Bengal Tiger']

# Your code here!

del zoo_animals['Sloth']
del zoo_animals['Bengal Tiger']
zoo_animals['Rockhopper Penguin'] = 2


print zoo_animals


#2

you only need to remove the Sloth and Bengal Tiger once, not twice like you have now


#3

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