Count Utility (wc)
easypy_stringsImplement count_util(text, flags=None) — a tiny wc-like counter.
flags is a command-line-style string selecting which counts to return:
-m → "chars" (number of characters), -l → "lines" (number of newline
characters), -L → "longest_line" (length of the longest line), -w →
"words" (whitespace-separated words). Flags may be combined ("-lm" or
"-l -m"). An empty string or None means all four. Return a dict containing
only the selected keys.
Your solution
Edit count_util and run the real pytest suite in your browser — no install required. Your code is saved locally.
Loading the Python runtime (first run only)…
Hints
Hint 1
Pull the flag letters out of the flags string (ignore '-' and spaces); empty/None means all four.
Hint 2
chars = len(text), lines = text.count('\n'), words = len(text.split()), longest_line = max line length.