Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊPython for Office WorkersModule 1 Β· Excel & CSV Β· Recapβ€ΊπŸŽ― Review: Automation module 1 recapscenario6 / 54
+80 XP
Task
Build `read_csv_dict(rows, key_col, val_col)` β€” the workhorse "turn a CSV into a lookup dict" helper: - `rows` is a list of dicts (think `DictReader` output). - Return a dict mapping `row[key_col]` β†’ `row[val_col]`. - If duplicate keys appear, LAST row wins (mirrors dict-update semantics). - Empty rows β†’ empty dict. - Missing key/val column in any row β†’ skip that row (defensive β€” partial data common in real CSVs).
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…