A tiny automated code review
The code being reviewed is held in a string and parsed, never executed.
AI coding assistants such as Copilot, Cursor, Claude Code and Codex write plausible Python quickly, and plausible is not the same as correct. Give them context, ask for tests, review what they produce, and verify with tests, type checks and Ruff before you trust it.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write find_bare_excepts(source) that returns the line numbers of bare except: clauses using ast.
Write slugify(title) and a function check_slugify() whose assertions cover normal, extra-space, empty and upper-case input.
Write first_word(text) that returns the first word, or an empty string for empty or blank text.
Explain it without notes
How do you give an AI assistant enough context to produce useful Python?
Name typical mistakes in AI-written Python and a way to catch each.
Why is it risky to accept AI-written code without tests?
A teammate opens a 600-line pull request that was mostly written by an AI assistant. How do you review it?
Expected output
line 2: mutable default argument in add_item()
line 8: eval() runs arbitrary code
line 9: bare except hides every error