Thuta Learning
ProjectsProgrammingbeginner

To-Do List (Enhanced)

Relax. We'll talk through this in plain words — no textbook voice.

🐍 Lesson 44: To-Do List App (Python Project)

1. Project Overview

In short → A To-Do List App is an app for collecting and managing daily tasks. Users can add new tasks, delete finished ones, and view a list of tasks that are still pending.

In detail → A To-Do List App helps users manage daily tasks by adding, viewing, and deleting tasks.

2. Why Build a To-Do List App?

  • You get to practice persisting data using file storage
  • You get to practice lists, dictionaries, loops, and functions
  • You can try out both the CLI version and the GUI version

3. Summary

✅ To-Do List App = beginner-friendly + practical project

✅ CLI version → practice with file storage + loops

✅ GUI version → Tkinter + listbox

✅ Error handling → invalid input, empty task

python
# ===== 1. File Storage Functions =====
import os

FILE_NAME = "tasks.txt"

def load_tasks():
    if not os.path.exists(FILE_NAME):
        return []
    with open(FILE_NAME, "r") as f:
        return [line.strip() for line in f]

def save_tasks(tasks):
    with open(FILE_NAME, "w") as f:
        for task in tasks:
            f.write(task + "\n")

# ===== 2. Display Tasks =====
def show_tasks(tasks):
    if not tasks:
        print("No tasks yet!")
    else:
        for i, task in enumerate(tasks, 1):
            print(f"{i}. {task}")

# ===== 3. Main To-Do List App =====
tasks = load_tasks()

print("===== To-Do List App =====")
print("Options: 1=Show, 2=Add, 3=Delete, 4=Quit\n")

# Simulated user interactions for demo
# In real app, use: choice = input("Choose: ")

# Example: Add tasks
tasks.append("Learn Python")
tasks.append("Build To-Do App")
save_tasks(tasks)
print("Tasks added!")

# Show tasks
print("\nCurrent Tasks:")
show_tasks(tasks)

# Example: Delete task
if len(tasks) > 0:
    tasks.pop(0)  # Remove first task
    save_tasks(tasks)
    print("\nAfter deletion:")
    show_tasks(tasks)
You should see
===== To-Do List App ===== Options: 1=Show, 2=Add, 3=Delete, 4=Quit Tasks added! Current Tasks: 1. Learn Python 2. Build To-Do App After deletion: 1. Build To-Do App
To-Do List (Enhanced) | Thuta Learning