Beginner project · about 40 minutes
Habit Tracker with Streaks 📅
Log daily habits and compute current and longest streaks from real dates. The logic behind every streak app.
Streaks are the hook in Duolingo, Strava and most habit apps. You will parse ISO dates, work out consecutive runs, and report the current streak as of a given "today".
What you will build
- Parse the log Each entry is "habit,YYYY-MM-DD". Build a dict of habit to a set of date objects using datetime.date.fromisoformat.
- Longest streak Sort the dates. Walk through them counting runs where each date is the previous plus one day.
- Current streak Starting from TODAY, step backwards one day at a time while the date is in the set.
- Report Print one line per habit: name, total days, current streak, longest streak.
Skills: datetime, sets, loops, sorting