Lazo Lab Sign up

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

Lesson 4 of 10

Listing tasks

Loop over the tasks with enumerate so each has a number, and show a tick for finished ones.

Key points

  • enumerate(tasks, start=1)
  • A conditional expression picks the mark
  • Handle the empty list
def list_tasks():
    if not tasks:
        print("Nothing to do. Nice!")
        return
    for i, t in enumerate(tasks, start=1):
        mark = "✔" if t["done"] else " "
        print(f"{i}. [{mark}] {t['text']}")

Your turn

Write list_tasks() and hook it up to choice 2.

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

Quiz · +10 XP

What does `if not tasks:` check?

Log in to save progress and earn XP.