2. This is KEY!


#1

code:

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 w in webster:
  print webster[w]

task:
Use a for loop to go through the webster dictionary and print out all of the definitions.

output:

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

question:

why the fork is it in the different order?

** In my defense I’d like to say that I actually did try other online compilers and it worked out the way I expected it to, I mean not mixed up or whatever.


#2

Because dictionaries do not remember the order in which data is inserted. They have no order, only structure.


#3

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