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β€ΊCreative ChallengesModule 4 Β· πŸ› Bug Bounty Β· Recapβ€ΊπŸŽ― Review: Creative module 4 recapscenario42 / 104
+80 XP
Task
Build `time_travel_refactor(old_code, modernize)` β€” a mock refactor pass that replaces 1998-era idiom keys with 2026 ones: - `old_code` is a string of Python source. - `modernize` is a dict mapping old-token β†’ new-token (e.g. `{"format(": "f-string("}`). - Replace every occurrence of each key with its value, in iteration order of the dict. - Empty `modernize` dict β†’ return `old_code` unchanged. - Empty `old_code` β†’ return `""`. This is the algorithmic core of an autofix pass β€” the real tool wraps an AST visitor around the same idea.
✏️ 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…