Dictionary print order

+3 ben pritchard · January 2, 2016
Hi, can someone tell me why the order of the items printed is not the same as the order inside the dictionary?

Post a Reply

Replies

Oldest  Newest  Rating
0 Sjoerd van den Belt · January 4, 2016
Because a dictionary is by default not sorted. Its value should be accessed by the corresponding key, unlike lists or tuples which can be accessed by their index. You can however make a sorted dictionary, see the following link for more information: http://stackoverflow.com/questions/9001509/how-can-i-sort-a-dictionary-by-key
  • 1

Python

107,204 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator