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