Lazo Lab Sign up

App 2: To-Do List Manager / Build the to-do app

Lesson 3 of 10

Adding tasks

Each task is a dictionary with its text and whether it's done. Adding a task appends a new dictionary to the list.

Key points

  • tasks = [] at the top
  • {"text": ..., "done": False}
  • Don't add empty tasks
tasks = []

def add_task():
    text = input("Task: ").strip()
    if text:
        tasks.append({"text": text, "done": False})
        print("Added!")

Your turn

Write add_task() and call it when the user picks 1.

Watch a video on thisOpens YouTube search results for “Adding tasks” in a new tab

Quiz · +10 XP

Which method adds an item to the end of a list?

Log in to save progress and earn XP.