Sub topic 10
Reviewing the numbers and adjusting the habit
This chapter assumes you have built the tracker from the earlier chapters. You need the current_streak, longest_streak and completion_rate functions, and you should be comfortable with sets of dates and with timedelta. The code below uses those functions as they were defined before.
Numbers only help if you act on them. In this chapter you will combine the three metrics into a single review, learn what each combination suggests, and decide what to change.
What each metric tells you
Each metric answers a different question.
| Metric | Question it answers | Weakness |
|---|---|---|
| Current streak | Am I on a run right now? | One missed day resets it to zero |
| Longest streak | What have I managed at my best? | It never goes down, so it can hide a recent decline |
| Completion rate | How often do I do it overall? | It ignores whether the days are consecutive |
Looking at one metric alone can mislead you. A streak of 0 after a single missed day looks like failure. A completion rate of 90% over 30 days says the habit is mostly sticking. Read together, they give a clearer picture.
Building a review function
First, collect the numbers into one place. This function reuses the earlier functions and returns a dictionary, so you can print it, test it or save it.
from datetime import date, timedelta
def current_streak(days, today=None):
today = today or date.today()
day = today if today in days else today - timedelta(days=1)
streak = 0
while day in days:
streak += 1
day -= timedelta(days=1)
return streak
def longest_streak(days):
best = run = 0
previous = None
for day in sorted(days):
if previous is not None and day - previous == timedelta(days=1):
run += 1
else:
run = 1
best = max(best, run)
previous = day
return best
def completion_rate(days, end, window=30):
start = end - timedelta(days=window - 1)
done = sum(1 for d in days if start <= d <= end)
return done / window
def review(days, today=None, window=30):
today = today or date.today()
return {
"current": current_streak(days, today),
"longest": longest_streak(days),
"rate": completion_rate(days, today, window),
}
days = {date(2026, 11, d) for d in (1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15)}
print(review(days, today=date(2026, 11, 15)))The output is {'current': 6, 'longest': 7, 'rate': 0.43333333333333335}. The person has a good current run and a decent best run. The 30-day rate is only about 43% because the window includes days before the habit started. Keep that in mind when you read the rate, because a new habit always looks low at first.
Reading the combinations
The pattern across the three numbers points to a likely cause.
- Current streak is close to the longest streak, and the rate is high. The habit is sticking. Leave it alone, or raise the goal slightly.
- Current streak is 0, but the rate is high. You missed recently but were consistent before. This is usually a slip, not a failure. Check in again today and rebuild.
- Longest streak is high, but the rate is low. You can do the habit in bursts but do not sustain it. The habit is probably too demanding for ordinary days.
- Everything is low. The habit as defined is not working. Change the habit, not the tracker.
The diagram shows this decision as a flow.
Adjusting the habit
Adjust one thing at a time, then review again after a fixed period such as two weeks. If you change several things, you cannot tell which change helped.
Common adjustments:
- Make it smaller. Change "run 5 km" to "put on running shoes and go outside". A smaller yes/no check is easier to log every day.
- Tie it to a trigger. Attach it to something you already do, such as "after breakfast".
- Change the window. A 7-day window reacts quickly. A 30-day window is steadier. Pick the one that matches how often you want to adjust.
- Raise the goal. If the rate stays above about 90% for several weeks, make the habit slightly harder.
Common mistakes
- Judging a new habit by its 30-day rate. Days before the start count as misses. Use a window no longer than the time since your first check-in.
- Reviewing too often. Daily rates swing widely. Review weekly.
- Ignoring the streak reset. One miss followed by a recovery is normal. Look at the rate before you decide the habit failed.
Exercise
A habit has a current streak of 0, a longest streak of 21, and a 30-day completion rate of 35%. Which reading from this chapter applies, and what is one sensible change?
Show answer
Longest streak is high while the rate is low, so the habit works in bursts but is not sustained. A sensible change is to make the habit smaller, for example reducing its daily requirement, and then review again after two weeks.
Exercise
Why can review(days, today) report a low completion rate for a habit that you started 10 days ago and did every day?
Show answer
The 30-day window includes 20 days before you started, and those days count as not done. Only 10 of 30 days are logged, so the rate is about 33%. Use a window that matches the time since your first check-in, such as window=10.