Dictionaries Are Unordered? - Codecademy

Skip to ContentProfile image of chipaggerSubmitted by chipaggeralmost 13 yearsdictionaries are unordered?

in 1.2 we are told

Note that dictionaries are unordered, meaning that any time you loop through a dictionary, you will go through every key, but you are not guaranteed to get them in any particular order.

what exactly does this mean? When I print out everything in a for loop it always produces the same order? Am I misunderstanding what the above means?

Answer 515efa81c89362526b000b80

0 votes

Permalink

Take a look at this example:

http://pythonfiddle.com/unordered-dict-example

When I iterate over the dictionary, the elements are not printed in the same order I used in the declaration. The order is usually consistent (that is, if I iterate again over the same dict, it should be the same) but you should not rely on this. (However, Python also has an ordered dictionary library.)

P.S. There’s one chance out of 16 that the dictionary will be printed in the correct order, but the concept remains :D

Profile image of DeKSubmitted by DeKalmost 13 years

Answer 5160261b160bbd52790018e5

0 votes

Permalink

Ok, I think I have an adequate grasp of it. Thanks for your help.

Profile image of chipaggerSubmitted by chipaggeralmost 13 years

Popular free courses

  • Free course

    Learn SQL

    In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
    • Checker DenseBeginner Friendly.4 Lessons
  • Free course

    Learn JavaScript

    Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Checker DenseBeginner Friendly.11 Lessons
  • Free course

    Learn HTML

    Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Checker DenseBeginner Friendly.6 Lessons
Explore full catalog

Tag » What Does Unordered Mean In Python