HomeCourse › Module 04

Control Flow

if / else / elif, for and while loops, and Python's gentle error-handling — try/except.

Foundations 6 lessons ~50 min

Lessons in this module

  1. if / else — making decisions · 8 min
    Python's IF() statement: indentation, elif, the comparison operators in action.
  2. for loops — doing something for every item · 9 min
    Loop through lists, ranges, dictionaries, and lines of a file.
  3. while loops — repeat until done · 6 min
    When you don't know how many iterations you need: while, break, and the infinite-loop pitfall.
  4. List comprehensions — one-line loops · 7 min
    The compact way to build a list from another list. Less code, more clarity.
  5. try / except — handling errors gracefully · 7 min
    Catch exceptions so your script keeps running instead of dying on bad data.
  6. Putting it together — a mini contact-cleaner · 8 min
    Combine if/for/comprehensions/try-except into your first useful script.