Distinct outage count

Write codeEasy10 min

Your task

An uptime checker probes a site once a minute and stores the results in order as a list of strings, each "up" or "down". For the monthly report you need the number of distinct outages: an outage is a maximal run of consecutive "down" results, it starts when a "down" follows an "up" (or begins the list) and ends at the next "up" (or the end of the list). Return the number of outages; an empty list has zero.

Examples

count_outages(statuses: list[str]) -> int
Example 1
Inputcount_outages(["up", "down", "down", "up", "down"])
Output2