Every Monday you compute MRR delta by hand — last week vs this week. What if you named that logic and called it every time?
After plan_summary I can see the per-plan totals. But formatting them into a ranked update line — '#1 Pro — MRR: $14,850 | Customers: 99 | ARPU: $150.00' — is still a manual copy-paste.
def make_update_line(plan, stats, rank): is your formula name. The indented block is the formula body. return gives back the formatted string. Write it once, call it every Monday — your Monday becomes make_update_line('pro', stats, 1):
def make_update_line(plan: str, stats: dict, rank: int) -> str:
"""Format a plan stats dict into a ranked investor update line."""
mrr = stats.get('total_mrr', 0)
customers = stats.get('total_seats', 0)
arpu = stats.get('avg_arpu', 0)
result = f"#{rank} {plan.title()} — MRR: ${mrr:,.2f} | Customers: {customers} | ARPU: ${arpu:.2f}"
print(f"Line: {result}")
return resultWhat does the triple-quoted string at the top do?
That's a docstring — it documents what the function does. Python's help() and IDEs read it. It doesn't run. Write one for every function you plan to reuse: one sentence, what it takes, what it returns.
def make_update_line(plan: str, stats: dict, rank: int) -> str:
"""Format a plan stats dict into a ranked investor update line."""
...I just automated the part of Monday morning I hate most — the ranked plan breakdown for the investor email.
Welcome to the point of no return. Once you've named the logic, you can't go back to doing it manually.
make_update_line takes plan_summary output directly. That chain — collect, aggregate, format — is the whole investor update in three functions.
.title() capitalises the first letter of each word — "pro" becomes "Pro". Useful when plan names come from a CSV in lowercase. Keep your display formatting in the leaf functions so the data stays clean.
A function is a named, reusable block of code. For investor updates, naming the formatting logic means every Monday becomes a single function call — change the format once and every report updates automatically.
def function_name(param1: type, param2: type) -> return_type:
"""One-sentence docstring."""
# body
return resultdef keyword, then name, then (params):return sends a value backA function without return returns None. Assigning result = make_update_line(...) and getting None means you forgot return.
Every Monday you compute MRR delta by hand — last week vs this week. What if you named that logic and called it every time?
After plan_summary I can see the per-plan totals. But formatting them into a ranked update line — '#1 Pro — MRR: $14,850 | Customers: 99 | ARPU: $150.00' — is still a manual copy-paste.
def make_update_line(plan, stats, rank): is your formula name. The indented block is the formula body. return gives back the formatted string. Write it once, call it every Monday — your Monday becomes make_update_line('pro', stats, 1):
def make_update_line(plan: str, stats: dict, rank: int) -> str:
"""Format a plan stats dict into a ranked investor update line."""
mrr = stats.get('total_mrr', 0)
customers = stats.get('total_seats', 0)
arpu = stats.get('avg_arpu', 0)
result = f"#{rank} {plan.title()} — MRR: ${mrr:,.2f} | Customers: {customers} | ARPU: ${arpu:.2f}"
print(f"Line: {result}")
return resultWhat does the triple-quoted string at the top do?
That's a docstring — it documents what the function does. Python's help() and IDEs read it. It doesn't run. Write one for every function you plan to reuse: one sentence, what it takes, what it returns.
def make_update_line(plan: str, stats: dict, rank: int) -> str:
"""Format a plan stats dict into a ranked investor update line."""
...I just automated the part of Monday morning I hate most — the ranked plan breakdown for the investor email.
Welcome to the point of no return. Once you've named the logic, you can't go back to doing it manually.
make_update_line takes plan_summary output directly. That chain — collect, aggregate, format — is the whole investor update in three functions.
.title() capitalises the first letter of each word — "pro" becomes "Pro". Useful when plan names come from a CSV in lowercase. Keep your display formatting in the leaf functions so the data stays clean.
A function is a named, reusable block of code. For investor updates, naming the formatting logic means every Monday becomes a single function call — change the format once and every report updates automatically.
def function_name(param1: type, param2: type) -> return_type:
"""One-sentence docstring."""
# body
return resultdef keyword, then name, then (params):return sends a value backA function without return returns None. Assigning result = make_update_line(...) and getting None means you forgot return.
You produce a weekly ranked plan breakdown for your investors — '#1 Pro — MRR: $14,850.00 | Customers: 99 | ARPU: $150.00'. Write `make_update_line(plan, stats, rank)` that takes a plan name, a stats dict with 'total_mrr', 'total_seats', 'avg_arpu' keys, and a rank int, and returns the formatted string.
Tap each step for scaffolded hints.
No blank-editor panic.