7. Dictionaries
When you have a collection of things like a list but you wish to give each item a unique name and then access those items by their names, it is best to arrange the values into a dictionary. Like lists, dictionaries can contain any number of values, such as numbers, people’s names, window names, channels, or command names. Dictionaries collect these values into a single entity that you can pass around like any other value, or nest inside other dictionaries or lists, and then you can retrieve those component values again by looking them up by their key name.
Dictionaries represent an ordered collection; dictionaries preserve the order of insertion of their keys and will iterate over them in that order. Dictionaries are represented ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access