Objective
Create a command-line tool with subcommands, like git does. Each subcommand is a different action with its own arguments. The arguments of each test are passed to the program as if you typed them in the terminal (they appear in the test cases).
Instructions
- Use
parser.add_subparserswithdest="command"(required) and define the subcommandsupper,reverse,statsandrepeat(the latter with an integer argumenttimes). - Read the text from standard input, line by line.
uppershows each line in uppercase;reverse, each line reversed;repeat times, each line repeatedtimestimes separated by spaces.statsshowsLines: kandWords: k(the total number of words in all the lines).
ab cd
ef
ab cd ab cd
ef ef
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise