← Back to Files
Question 439
Errors Pulled From A Log
Errors Pulled From A Log
Input: the first line is a whole number n, then n log lines, each starting with the level INFO, WARN or ERROR followed by a space and a message; no prompts. Write them to app.log one per line (a for over range(n) reads them with input()), read that file back with readlines, and write only the lines whose level is ERROR to errors.log, unchanged. Find the level with split() and compare the first word with an if / elif chain that also counts each level. Finally print INFO: <count>, WARN: <count> and ERROR: <count> on three lines, then the content of errors.log read with f.read() and printed with end="" (nothing more when it is empty).
Expected Output:
INFO: 1 WARN: 1 ERROR: 2 ERROR disk full ERROR timeout
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Files
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.