Chapter 11. Dictionaries and Sets

When you store data in an array, you can retrieve it by searching for that specific data or by keeping track of the index position of that data. Since searching for data or storing index positions of data can be cumbersome, there are two other data structures you can use called a dictionary and a set.

Dictionaries act like arrays, but they contain a paired key for each stored value, allowing you to search for a stored value just by knowing its key. Sets make it easy to compare lists and are useful for grouping items and determining whether one set is a subset or intersection of another set.

In this chapter, we explore the ins and outs of both of these data structures.

Dictionary Basics

A dictionary stores two chunks ...

Get Mac Programming for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.