You are here: Practice · To-do

A file is notes the program can reread

Ask for a task. Save it into a text file.

Until now the phone forgot when the script ended. A file is how a program leaves a sticky note on disk. Week 3 work. If files still feel new, write one line and stop.

Goal

A script that asks “What do you need to do?” and appends that line to a file such as todo.txt in ~/learn.

Starter shape

Get the text with input. Open a file in add-on mode. Write the line. Close. Then run cat todo.txt in the shell to see it without Python.

A little deeper

Open, write, close is a tiny recipe. Later you will wrap that recipe in a function so you can reuse it. Not required today.

If it breaks

Wrong folder. You are not standing in ~/learn. Run pwd. If the file exists but looks empty, you opened it in a mode that replaces instead of adding. Ask Grok about append versus write, using a notebook example.