Loops

Loops let you repeat code without copying. Learn while, for, and do-while to iterate over data.

58 lessons
233 min

Lessons

1. Intro

The Goal

4m

2. What is a Loop?

The concept of iteration

4m

3. The while Loop

Basic while loop structure

4m

4. while Loop Syntax

How to write while loops

4m

5. Loop Condition

Understanding the test

4m

6. Quiz: while Basics

Test understanding

3m1 problems

7. Counting with while

Using loops to count

4m

8. Infinite Loops

Loops that never stop

4m

9. Loop Variables

Variables that control loops

4m

10. Quiz: while Patterns

Test understanding

3m1 problems

11. The for Loop

Counting made simple

4m

12. for Loop Syntax

Structure breakdown

4m

13. The Initialization Part

Starting the loop

4m

14. The Condition Part

When to keep going

4m

15. Quiz: Repetition basics

Repetition basics

3m1 problems

16. The Update Part

Advancing the counter

4m

17. Challenge: Print Numbers

Basic for loop

5m1 problems

18. Quiz: for Loop Structure

Test understanding

3m1 problems

19. Counting Up

Standard forward iteration

4m

20. Counting Down

Reverse iteration

4m

21. Quiz: Post-check loop

Post-check loop

3m1 problems

22. Custom Step Sizes

Non-unit increments

4m

23. Challenge: Sum of Numbers

Loop with accumulator

5m1 problems

24. Quiz: for Variations

Test understanding

3m1 problems

25. for vs while

When to use each

4m

26. The do-while Loop

Execute then check

4m

27. Quiz: Condition-based loop

Condition-based loop

3m1 problems

28. do-while Syntax

How to write do-while loops

4m

29. When to Use do-while

Guaranteeing first execution

4m

30. Quiz: Condition-based loop

Condition-based loop

3m1 problems

31. Quiz: do-while

Test understanding

3m1 problems

32. The break Statement

Stopping loops mid-execution

4m

33. Breaking from Loops

When to exit early

4m

34. Challenge: Factorial

Multiplication loop

7m1 problems

35. Quiz: Loop exit

Loop exit

3m1 problems

36. The continue Statement

Jumping to next iteration

4m

37. Skipping to Next Iteration

When to use continue

4m

38. Quiz: Skip iteration

Skip iteration

3m1 problems

39. Quiz: break and continue

Test understanding

3m1 problems

40. Nested Loops

Multi-level iteration

4m

41. Nested Loop Patterns

Common use cases

4m

42. Common Loop Mistakes

Avoiding boundary bugs

4m

43. Problem - Sum of Numbers

Adding values in a loop

4m1 problems

44. Problem - Football

Finding dangerous patterns

4m1 problems

45. Football - Core Idea

Main approach

5m

46. Football - Algorithm

Breaking down the solution

4m

47. Quiz: Repetition basics

Repetition basics

3m1 problems

48. Football - Implementation

Working solution

7m1 problems

49. Football - Walkthrough

Following the execution

5m

50. Lessons from Football

What we learned

4m

51. Problem - Nearly Lucky

Checking lucky property

4m1 problems

52. Nearly Lucky - Core Idea

Main approach

4m

53. Nearly Lucky - Algorithm

Breaking down the solution

4m

54. Quiz: Repetition basics

Repetition basics

3m1 problems

55. Nearly Lucky - Implementation

Working solution

7m1 problems

56. Nearly Lucky - Walkthrough

Following the execution

5m

57. Lessons from Nearly Lucky

What we learned

4m

58. Section Recap

What we learned

5m

Ready to start learning?

Access all 58 lessons with interactive content and progress tracking.