LearnPy Hub
← File Handling problems
Hard

Log File Report

Read log lines YYYY-MM-DD HH:MM:SS LEVEL message until END and write them to app.log. Then read the file back and print: the count of each level (alphabetical) as LEVEL n, the busiest hour as busiest hour HH (n lines) (earliest hour if tied), and the last ERROR message or no errors.

Input

Lines, then END.

Output

Lines.

Sample 1

Input
2026-11-14 09:00:01 INFO started
2026-11-14 09:15:22 ERROR disk full
2026-11-14 10:01:00 INFO retry
2026-11-14 09:59:59 WARN slow
END
Output
ERROR 1
INFO 2
WARN 1
busiest hour 09 (3 lines)
disk full

Sample 2

Input
2026-01-01 00:00:00 INFO only line
END
Output
INFO 1
busiest hour 00 (1 lines)
no errors
solution.py
Output appears here
Log File Report · Python practice problem · LearnPy Hub