This is KEY!


#1

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."
}

for key in webster:
    print webster

Why does it say it does not print something, when it prints it 3 times?


#2

And how do I fix my wrongly made mistake here? I would love to hear the answer


#3

webster is the dictionary object. We wish to print only the keys, or only the values.

for key in webster:
    print key

Will print,

Aardvark
Baa
Carpet
Dab
for key in webster:
    print webster[key]

Will print the values.

A star of a popular children's cartoon show.
The sound a goat makes.
Goes on the floor.
A small amount.

#4

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