Pybites Logo Rust Platform

wc: Count Lines, Words, and Characters

Easy +2 pts

🎯 The Unix wc ("word count") tool reports how many lines, words, and characters a file holds.

In Python you'd lean on the string methods:

def wc(text):
    return (
        len(text.splitlines()),   # lines
        len(text.split()),        # words
        len(text),                # characters
    )

This is the first tool in the unix-tools track.

Every tool here follows the same shape: a pure function does the counting/transforming, and in a real CLI a thin wrapper would feed it text from a file or stdin.

You implement and test just the pure function here; keeping the logic …

Login to see the full exercise.