Write a function. Test real cases. Improve your solution.
Given a list of status strings, replace each consecutive run of equal statuses with {"status": string, "count": integer}. Keep runs in their original order. A status that reappears after a different status starts a new run; do not combine it with an earlier run. Comparison is case-sensitive, and the empty string is a valid status. Empty input returns []. Leave the list unchanged.
[["up", "up", "down", "up"]]
[{"status": "up", "count": 2}, {"status": "down", "count": 1}, {"status": "up", "count": 1}][[]]
[]
[["queued", "running", "done"]]
[{"status": "queued", "count": 1}, {"status": "running", "count": 1}, {"status": "done", "count": 1}][["idle", "idle", "idle", "idle"]]
[{"status": "idle", "count": 4}][["", "", "ready", ""]]
[{"status": "", "count": 2}, {"status": "ready", "count": 1}, {"status": "", "count": 1}][["OK", "ok", "ok", "OK"]]
[{"status": "OK", "count": 1}, {"status": "ok", "count": 2}, {"status": "OK", "count": 1}]Python 3.14 runs in your browser. The first run downloads about 13 MB; your browser can cache it for later visits. Each run starts fresh. Use synchronous functions and core standard-library modules. Network requests, package installs, and interactive input() are unavailable. Return lists, string-key dictionaries, strings, finite numbers, bools, or None. Student code stops after about four seconds, after Python loads. Python engine credits. Test results support self-study and don’t certify proficiency.