A data structure organizes data so a program can transform and compare it meaningfully. Reading a country-and-population file as a string makes comparisons awkward; reading it into a dict makes comparing France and Thailand straightforward. section 5.10
Useful file-to-structure exercises include:
- Count each vowel in a text file with a dict. section 5.5
- Group users by login shell, storing each shell’s users in a list. section 5.10
- Represent each username with a nested dict containing user ID, home directory, and shell. section 5.10
The same translation applies to standard formats such as CSV and JSON: move between file text and built-in Python data types, then operate on the resulting structure. section 5.36









