Example 1 — Grow a Daily To-Do List
Add tasks one at a time and print what append() itself returns.
todo = ["buy milk", "call mom"]
print(todo.append("pay rent"))
print(todo)
todo.append("water plants")
print(len(todo), todo[-1]) How It Works
- The return value is None.
print(todo.append("pay rent"))still adds the task, but the method hands backNone, and that is what gets printed. - Changed in place. Printing
todoafterwards shows the new task at the end; no second list was made. - Always the end. The next call adds "water plants" after "pay rent", so the list now holds four tasks.
- Negative index for the newest.
todo[-1]reads the item that was appended last.

