12. Changing your mind


#1

Man I'm having so much trouble with this course. The person who wrote this section needs to do a much better job I've been stuck on this section for two days now, my code.

key - animal_name : value - location

zoo_animals = { 'Unicorn' : 'Cotton Candy House': 'Rainforest Exhibit': '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!

zoo_animals['Rockhopper Penguin'] = 'Arctic Exhibit'

print zoo_animals

"Oops, try again.
Your code looks a bit off. Double check the examples in the
instructions if you need help! Your code threw the following error:
invalid syntax (python, line 2)" I'm just ready to give up on Codeacademy.


#2

@accollins,
The Instructions:

Delete the 'Sloth' and 'Bengal Tiger' items from zoo_animals using del.

Set the value associated with 'Rockhopper Penguin' to

anything other than 'Arctic Exhibit'.


#3

this is my 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']

Your code here!

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

print zoo_animals


#4

You're not getting saying it can equal anything minus Arctic Exhibit. I don't remember that lesson too well so if you could send me a link to the lesson I could tell you.


#5

You're not saying minor grammatical mistake.


#6

Thank you for reply ,plz tell me
https://www.codecademy.com/courses/python-beginner-en-pwmb1/2/3?curriculum_id=4f89dab3d788890003000096#


#7

you haven't in your dictionary key"4" -> zoo_animals[4]
use:
zoo_animals['Rockhopper Penguin']='hello world'


#8

It worked.
but why it wasnot ['Arctic Exhibit']='hello world' ?
= donot mean replacement?


#9

I don't get it my code is

key - animal_name : value - location

zoo_animals = { 'Unicorn' : 'Cotton Candy House',
'Rainforest Exhibit' : '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']

print zoo_animals

                                                         But the error code says:

                                Oops, try again. Check that you spelled the key strings correctly!

#10

Set the value associated with 'Rockhopper Penguin' to anything other than 'Arctic Exhibit'.--You didnot finish this Instruction.


#11

Try to understand the code before cut, copy and runinnig it!!

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']# Your code here!
del zoo_animals['Bengal Tiger']
zoo_animals['Rockhopper Penguin']= 'ice age'

print zoo_animals


#12

Is there anyway to delete multiple name and value pairs at once?
like del zoo_animals['name1','name2' ] ????


#13

@textrunner52446,
Try google search
== discussions / opinions ==
python deleting multiple list element at once site:stackoverflow.com
like
http://stackoverflow.com/questions/497426/deleting-multiple-elements-from-a-list


#14

Thanks for all the help i finally understood it


#15

why the stupid python cannot support del dict_name ['key1', 'key2']


#16

yeah, That's what I'm thinking.


#17

@textrunner52446,
@boardslayer95180,
@byteace83915,
Maybe you should get used to the Python way of doing the multiple deletion
http://stackoverflow.com/questions/8995611/removing-multiple-keys-from-a-dictionary-safely


#18

thx, It's very kind of you. well, if I have something else need to know, may I ask you?


#19

so freaky man we know that show the code ???


#20

my code is this. it says I didn't spell it correctly

# 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'}
# 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' , 'Bengal Tiger']



print zoo_animals

do you know what happened?