Level 6Exercise #145
Group events by day
Group (ISO timestamp, event) pairs by calendar date.
What you’ll practice
This Level 6 exercise focuses on datetime.date in the Professional curriculum. Solve the challenge prompt above using clear, idiomatic Python and the relevant language or standard-library tools.
Relevant Python reference: datetime — Basic date and time types.
Sample Test Cases
Example #1
Input:
events_by_day([('2026-08-05T10:00:00', 'e1'), ('2026-08-05T12:00:00', 'e2')])Output:
{date(2026,8,5): [...]}Further Reading
Reference Solution
Reveal Reference Solution
def events_by_day(rows: list[tuple[str,str]]): from collections import defaultdict from datetime import datetime grouped = defaultdict(list) for timestamp, event in rows: grouped[datetime.fromisoformat(timestamp).date()].append(event) return dict(grouped)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.