Loops
Loops let you repeat code without copying. Learn while, for, and do-while to iterate over data.
Lessons
1. Intro
The Goal
2. What is a Loop?
The concept of iteration
3. The while Loop
Basic while loop structure
4. while Loop Syntax
How to write while loops
5. Loop Condition
Understanding the test
6. Quiz: while Basics
Test understanding
7. Counting with while
Using loops to count
8. Infinite Loops
Loops that never stop
9. Loop Variables
Variables that control loops
10. Quiz: while Patterns
Test understanding
11. The for Loop
Counting made simple
12. for Loop Syntax
Structure breakdown
13. The Initialization Part
Starting the loop
14. The Condition Part
When to keep going
15. Quiz: Repetition basics
Repetition basics
16. The Update Part
Advancing the counter
17. Challenge: Print Numbers
Basic for loop
18. Quiz: for Loop Structure
Test understanding
19. Counting Up
Standard forward iteration
20. Counting Down
Reverse iteration
21. Quiz: Post-check loop
Post-check loop
22. Custom Step Sizes
Non-unit increments
23. Challenge: Sum of Numbers
Loop with accumulator
24. Quiz: for Variations
Test understanding
25. for vs while
When to use each
26. The do-while Loop
Execute then check
27. Quiz: Condition-based loop
Condition-based loop
28. do-while Syntax
How to write do-while loops
29. When to Use do-while
Guaranteeing first execution
30. Quiz: Condition-based loop
Condition-based loop
31. Quiz: do-while
Test understanding
32. The break Statement
Stopping loops mid-execution
33. Breaking from Loops
When to exit early
34. Challenge: Factorial
Multiplication loop
35. Quiz: Loop exit
Loop exit
36. The continue Statement
Jumping to next iteration
37. Skipping to Next Iteration
When to use continue
38. Quiz: Skip iteration
Skip iteration
39. Quiz: break and continue
Test understanding
40. Nested Loops
Multi-level iteration
41. Nested Loop Patterns
Common use cases
42. Common Loop Mistakes
Avoiding boundary bugs
43. Problem - Sum of Numbers
Adding values in a loop
44. Problem - Football
Finding dangerous patterns
45. Football - Core Idea
Main approach
46. Football - Algorithm
Breaking down the solution
47. Quiz: Repetition basics
Repetition basics
48. Football - Implementation
Working solution
49. Football - Walkthrough
Following the execution
50. Lessons from Football
What we learned
51. Problem - Nearly Lucky
Checking lucky property
52. Nearly Lucky - Core Idea
Main approach
53. Nearly Lucky - Algorithm
Breaking down the solution
54. Quiz: Repetition basics
Repetition basics
55. Nearly Lucky - Implementation
Working solution
56. Nearly Lucky - Walkthrough
Following the execution
57. Lessons from Nearly Lucky
What we learned
58. Section Recap
What we learned