Count log lines by level
Your task
Your web server writes one log line per event in the format "<timestamp> <LEVEL> <message>", for example "2026-07-01T10:00:00 ERROR auth timeout". The level is always the second space-separated token. Given the log lines in order and a level name such as "ERROR", return how many lines were logged at exactly that level. Match the level token exactly, a line whose message merely mentions the word does not count.
Examples
count_level(lines: list[str], level: str) -> intExample 1
Input
count_level(["2026-07-01T10:00:00 ERROR auth timeout", "2026-07-01T10:00:05 INFO user login", "2026-07-01T10:00:09 ERROR db connect failed"], "ERROR")Output
2