Level 1Exercise #18
Index records by ID
Convert user dictionaries into one dictionary keyed by user id.
Sample Test Cases
Example #1
Input:
index_by_id([{"id": 7, "name": "Mira"}])Output:
{7:{'id':7,'name':'Mira'}}Further Reading
Reference Solution
Reveal Reference Solution
def index_by_id(records: list[dict]) -> dict[int, dict]: return {record['id']: record for record in records}Pro Tips & Keyboard Shortcuts
Color Theme
Ctrl + K then T
Open VS Code Color Theme Quick Pick to select from 20 dark and light themes.
Editor SettingsCtrl + K
Open practice settings drawer to toggle line numbers, indenting, font size & hints.
Search MenuCtrl + /
Expand sidebar menu, focus search bar, and highlight search text instantly.
Focus Code Editor
Esc or Ctrl + `
Instantly highlight and focus code editor from anywhere, restoring cursor right where you left off.
Normal ViewEsc
Collapse sidebar and close all popups or settings drawers for clean focus view.