DS 1501 · Lesson 10 of 24
Instructor: Corey Schafer10m
Sign in to watchMaster multi-level iteration and fine-grained flow interruption using break, continue, loop-else clauses, and 2D/pattern nested loops. What you will learn: • break: immediately terminates the innermost enclosing loop. • continue: skips remaining body statements in the current iteration and jumps to the next step. • Loop else clause (runs only if the loop finished normally WITHOUT hitting break — ideal for prime/search checks). • Nested loops (outer row loop i, inner column loop j): printing star/number triangles, multiplication grids, and scanning 2D tables. University Outline Mapping: Class 10 · CO3 · Reading: Chapter 7 (crash) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 10 | CO3 | Reading: Crash Course Ch. 7 Exam Trace Pitfalls (Midterms 241, 243, 253): • continue inside a while loop: NEVER skip the counter increment before continue, or you create an infinite loop! • break in a nested inner loop ONLY exits the inner loop; the outer loop keeps running. 2D Nested Loop Pattern: for i in range(1, 4): for j in range(1, i + 1): print(j, end=" ") print()
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