12. Changing Your Mind


#1



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


Not sure what's wrong with my code

The error is "Oops, try again. It looks like Arctic Exhibition was added; did you misspell "Rockhopper Penguin"?"


# 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']

# Your code here!
del zoo_animals['Sloth']
del zoo_animals['Bengal Tiger']
zoo_animals['Rockhopper Penguin'] = 9
zoo_animals['Arctic Exhibition'] = 1
print zoo_animals


#2

Set the value associated with 'Rockhopper Penguin' to anything other than 'Arctic Exhibit'.

This expects a change of value to an existing member, not addition of a new one.

'Rockhopper Penguin': 'Arctic Exhibition'

#3

Like this? I'm not sure..

# 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']

# Your code here!
del zoo_animals['Sloth']
del zoo_animals['Bengal Tiger']
zoo_animals['Rockhopper Penguin'] = 9
zoo_animals['Arctic Exhibition'] = 1
'Rockhopper Penguin' : 'Arctic Exhibition'
print zoo_animals

#4

I guess I was being too cryptic. I wrote what the lesson checker was looking for, not the code to make that change happen.

Remove both lines above, and change the 9 in this line to 'Arctic Exhibition'...

zoo_animals['Rockhopper Penguin'] = 9

#5

Thanks wasn't sure what was wrong


#6

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