Lesson 3.1
Lists and Slicing
Lists are ordered and mutable. A slice takes start, stop, and step, and the stop index is excluded.
The four built-in collections and the habit of choosing between them. Most of the awkwardness in beginner Python comes from solving a dictionary problem with parallel lists.
Lesson 3.1
Lists are ordered and mutable. A slice takes start, stop, and step, and the stop index is excluded.
Lesson 3.2
A dictionary maps keys to values with constant average lookup. Keys must be hashable, which excludes lists.
Lesson 3.3
A set stores unique unordered items with fast membership testing. A tuple is an immutable sequence, which makes it hashable and usable as a dictionary key.
Lesson 3.4
A comprehension builds a collection from an iterable in one expression, and is clearer than an accumulating loop when the logic is simple.
Work through questions with a tutor and get help with the steps you find difficult.
Get help with this topic