Search RU
Tasks / Logs / Error rate in logs
Statement easy

Error rate in logs

`error_rate(lines)` counts the share of `ERROR` lines among valid log lines.

A valid line looks like this:

```
ERROR /orders 12ms
INFO /health 5ms
```

Format: uppercase level, path, duration in milliseconds. Everything else is noise
and is ignored.

Requirements:

- only valid lines are counted;
- `ERROR` matches exactly, uppercase only;
- an empty list or zero valid lines returns `0.0`.

Write tests for: a mixed log, noise, empty input, and lowercase.

logsregexedge cases
test_solution.py Python 3.14
AI mentor

The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.

Log in and ask
Hints 1 of 3 unlocked · attempts: 0
Hint 1

What counts as a valid line? Valid and noisy lines affect the denominator
differently — check that separately.

Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts