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 FoundationsModule 2 Β· Data structuresβ€ΊπŸŽ― Review Β· build + look up a contact bookscenario32 / 174
+50 XP
Task
Build a small phone-book helper. 1. The starter already creates `contacts = {"Anna": "111", "Boris": "222", "Clara": "333"}`. 2. Write `lookup(name)` that returns `contacts.get(name, "unknown")` β€” so missing names don't crash. 3. Print `lookup("Anna")` and `lookup("Dan")` (Dan is not in the dict). 4. Use a list comprehension to print a list of names whose length is even (use `len(name) % 2 == 0`). For this dict that's `['Anna', 'Clara']`. Expected output (three lines): ``` 111 unknown ['Anna', 'Clara'] ```
✏️ 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…