Add Support for Counting the Characters (Task)

In this task, you’ll extend the functionality of the wordcount command by adding support for counting characters. Character counting will complement the existing feature of counting lines, words, and bytes, effectively emulating the behavior of the --chars flag in the original wc command.

Acceptance Criteria

  • The program should support any combination of the following command-line options: --lines, --words, --bytes, and --chars.
  • When the --chars flag is used alone, only the character count should be displayed.
  • Any combination of other flags should also be supported.
  • In the absence of command-line flags, your program should default to displaying lines, words, and bytes.
  • The displayed counts should always follow this order: lines, words, characters, bytes.
  • The program should count a multi-byte Unicode codepoint as a single character.

Examples

Running the command with no command-line flags:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.