LearnPy Hub
← Regular Expressions problems
Medium

Count Log Levels

Read log lines like [ERROR] disk full until END. Using a regular expression with a group, count the lines per level and print LEVEL N in alphabetical order. Ignore lines without a level.

Input

Lines, then END.

Output

Lines.

Sample 1

Input
[ERROR] disk full
[INFO] started
[ERROR] retry
noise
END
Output
ERROR 2
INFO 1

Sample 2

Input
[DEBUG] x
END
Output
DEBUG 1
solution.py
Output appears here
Count Log Levels · Python practice problem · LearnPy Hub