Part 3: Data¶
This part covers the built-in ways to hold many values: strings, lists, tuples, dictionaries, and sets. It then shows how to take parts of a sequence with slicing and how to build collections in one expression with comprehensions. Work through the lessons in order, because the later lessons use lists and indexes from the earlier ones.
- Strings: Read characters, call methods such as
upperandreplace, and build text with f-strings. ~15 min - Lists: Store ordered, changeable collections, and add, remove, sort, and loop over their items. ~20 min
- Tuples: Store fixed groups of values, and unpack them into several names in one line. ~15 min
- Dictionaries: Look up values by key, and count or group data with
get. ~20 min - Sets: Keep unique values, test membership, and combine collections with set operations. ~15 min
- Slicing: Take a part of a string or list with
start:stop:step, and reverse it. ~15 min - Comprehensions: Build lists, dictionaries, and sets in one expression, with an optional filter. ~20 min