Add and list tasks (Todo App)

A todo app is a list you can change. Read commands, one per line. add <text creates a task with the next id (1, 2, 3…) and prints added <id <text; an empty text prints error: empty task. list prints every task as <id [ ] <text, or (no tasks). Anything else prints error: unknown command.

Input: One command per line.

Output: One line per command (several for list).

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Keep the tasks in a list (or a map from id to task) and a counter for the next id.

More Todo App practice