CJCoding With Joseph
15free / daySign inCreate account

Append One More Task

Two tasks are written to todo.txt in write mode and a third, read from input, is added in append mode so the first two survive. Open the file a third time for reading, loop over its lines, add 1 to number before each print, trim the newline with rstrip, and show every task as the number, a full stop, a space and the task text, one per line. Input: one line, the new task, no prompt.

Expected Output:

1. buy milk
2. call Sam
3. walk the dog

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Files
📥 Auto-Input:
walk the dog\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.