Python Lists and Dictionaries: Changing your Mind


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.

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


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


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