Chapter 4

Cruising Massive Data with Dictionaries

IN THIS CHAPTER

check Producing a data dictionary

check Seeing how to loop through a dictionary

check Copying dictionaries

check Deleting items in a dictionary

check Using multi-key dictionaries

Data dictionaries, also called associative arrays in some languages, are kind of like lists, which we discuss in Chapter 3 of this minibook. But each item in the list is identified not by its position in the list but by a key. You can define the key, which can be a string or a number. All that matters is that it is unique to each item in the dictionary.

To understand why uniqueness matters, think about phone numbers, email addresses, and Social Security numbers. If two or more people had the same phone number, whenever someone called that number, all those people would get the call. If two or more people had the same email address, all those people would get the same email messages. If two or more people had the same Social Security number, and one of those people was ...

Get Python All-in-One For Dummies, 2nd Edition 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.