Python Series track

Project 5 · Practice Projects

Project 5 — To-Do List App

Build a full-featured to-do list with priorities, due dates, categories, and JSON file persistence.

Practice Projects1 min readFree lesson

Difficulty: Lv ★★ | Prerequisite Knowledge: Basics Weeks 6-9

Goal

To-Do Add/View/Complete/Delete + Priority + Due Date

Differences from Basic Assignment

  • Basic Week 10 Framework = 3 commands: add/show/done
  • Here = 5 commands + Priority + Due Date + Sorting·Filtering

Requirements

  • Data: [{"task": str, "done": bool, "priority": str, "due": str}, ...]
  • Commands: add, list, done <number>, del <number>, quit
  • Priority (High/Medium/Low)
  • list --pending, list --sort priority

Challenge Task

  • Emphasize Upcoming Deadlines
  • Category (Tag)

Assignment

Show the reference solution

Try the assignment yourself first — comparing your attempt with a working solution is where most of the learning happens.

solution.pyPython
"""To-Do List — Priority and Deadline Support"""

PRIORITY_ORDER = {"High": 0, "Medium": 1, "Low": 2}
todos = []

def add():
    task = input("To-Do:").strip()
    if not task: return
    p = input("Priority (High/Medium/Low, default Medium):").strip() or "Medium"
    if p not in PRIORITY_ORDER:
        p = "Medium"
    due = input("Deadline (YYYY-MM-DD, press Enter if none):").strip()
    todos.append({"task": task, "done": False, "priority": p, "due": due})
    print("Added")

def show(args=""):
    items = list(enumerate(todos, 1))
    if "--pending" in args:
        items = [(i, t) for i, t in items if not t["done"]]
    if "--sort priority" in args:
        items.sort(key=lambda x: PRIORITY_ORDER[x[1]["priority"]])
    if not items:
        print("(Empty)"); return
    for i, t in items:
        mark = "[x]" if t["done"] else "[ ]"
        due = f"~{t['due']}" if t["due"] else ""
        print(f"{i}. {mark}[{t['priority']}] {t['task']} {due}".rstrip())

def main():
    while True:
        raw = input("\n> ").strip()
        if not raw: continue
        parts = raw.split(maxsplit=1)
        cmd = parts[0]
        arg = parts[1] if len(parts) > 1 else ""
        if cmd == "quit": break
        elif cmd == "add": add()
        elif cmd == "list": show(arg)
        elif cmd == "done":
            try:
                idx = int(arg) - 1
                if 0 <= idx < len(todos):
                    todos[idx]["done"] = True
                    print("Completed")
                else:
                    print("No Number")
            except ValueError:
                print("Please enter a number")
        elif cmd == "del":
            try:
                idx = int(arg) - 1
                if 0 <= idx < len(todos):
                    del todos[idx]
                    print("Delete")
            except ValueError:
                print("Please enter a number")
        else:
            print("Unknown command")

if __name__ == "__main__":
    main()

Learn this lesson with a mentor

Work through the Python Series track on your own, or join a guided cohort at our Pitampura campus and online.

Call NowEnroll Now