Why does this work? ex 2 this is KEY


#1



https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/0/2?curriculum_id=4f89dab3d788890003000096


I don't understand why this code works. Please someone explain.


I'm sure its not supposed to work as it states in the instructions that it will read out definitions of the words and the console only outputs the 4 words and none


webster = {
	"Aardvark" : "A star of a popular children's cartoon show.",
    "Baa" : "The sound a goat makes.",
    "Carpet": "Goes on the floor.",
    "Dab": "A small amount."
}

# Add your code below!
for webster in webster:
    print webster


#2

this will loop over the dictionary:

for webster in webster:

I wouldn't give the iterator the same name as the dictionary.

Anyway, webster gets assigned all keys of the dictionary, and you print them

Just ignore the None


#3

Thanks, I'll keep that in mind.


#4

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