Lazo Lab Sign up

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

Lesson 6 of 10

Marking done and deleting

With pick_task in place, marking done is one line and deleting is one line. Reusing helpers keeps code short.

Key points

  • tasks[i]["done"] = True
  • tasks.pop(i) removes and returns it
  • Check for None first
def mark_done():
    i = pick_task()
    if i is not None:
        tasks[i]["done"] = True

def delete_task():
    i = pick_task()
    if i is not None:
        removed = tasks.pop(i)
        print(f"Deleted: {removed['text']}")

Your turn

Add mark_done() and delete_task() to choices 3 and 4.

Watch a video on thisOpens YouTube search results for “Marking done and deleting” in a new tab

Quiz · +10 XP

Why check `if i is not None` instead of `if i`?

Log in to save progress and earn XP.