April 2026
Intermediate
683 pages
25h 29m
English
The final collection type, dictionaries, is a little different than arrays and sets. Arrays and sets are lists of elements of the same type. Their selling point is their ability to contain multiple elements. A dictionary, meanwhile, is a flat structure containing key-value pairs.
The difference is highlighted in Figure 3.12. On the left side, userNames is an array holding a list of strings, reflecting the names of users in a system. On the right side, currentUser is a dictionary containing details about the current user.
Figure 3.12 Array and Dictionary, Side by Side
In this example, you can imagine the array as a list ...
Read now
Unlock full access