DS 1501 · Lesson 8 of 24
Instructor: Corey Schafer23m
Sign in to watchDeepen your mastery of Python iteration: how iterables and iterators work under the hood, lazy range() sequences, parallel-list indexing, and concise augmented assignments. What you will learn: • Iterables vs Iterators: iter(obj) and next(it) protocol, and why range() is memory-efficient. • Three forms of range(stop), range(start, stop), and range(start, stop, step) including negative steps. • Index-driven loops with range(len(lst)), enumerate(lst), and zip(names, scores) for parallel lists. • Augmented assignment operators (+=, -=, *=, /=, //=, %=, **=) and list mutation subtle difference vs rebinding. University Outline Mapping: Class 8 · CO2 · Reading: 3.8, 3.9 (Deitel), Chapter 3-4 (crash) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 08 | CO2 | Reading: Deitel 3.8–3.9 & Crash Course Ch. 3–4 High-Frequency Exam Traces: list(range(2, 8, 2)) -> [2, 4, 6] (8 is excluded!) list(range(10, 1, -3)) -> [10, 7, 4] list(range(5, 5)) -> [] Parallel List Pattern (Midterm 233 & 243 favorite): for i in range(len(items)): print(items[i], prices[i]) Caution: Avoid removing elements from a list while iterating over it forward — indices shift and skip items.
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community