Python To-Do List App Project – Build a To-Do List Using Python

Introduction

A To-Do List App is one of the most practical Python projects for beginners. It helps users organize their daily tasks by allowing them to add, view, update, and delete tasks. This project introduces important programming concepts such as lists, functions, loops, conditional statements, file handling, and user input validation.

To-Do List App in Python helps developers understand how CRUD (Create, Read, Update, Delete) operations work in software applications.

Project Workflow


Start
 ↓
Display Menu
 ↓
Add/View/Update/Delete Task
 ↓
Perform Selected Action
 ↓
Show Updated Task List
 ↓
Continue?
 ↓
Yes → Repeat
No → Exit

Algorithm

  1. Create an empty task list.
  2. Display menu options.
  3. Ask the user to choose an option.
  4. Perform the selected operation.
  5. Update the task list.
  6. Repeat until the user exits.
  7. Save tasks if required.

Basic To-Do List App

Source Code:


tasks = []
while True:
    print("\n1. Add Task")
    print("2. View Tasks")
    print("3. Exit")
    choice = input("Enter Choice: ")
    if choice == "1":
        task = input(
            "Enter Task: "
        )
        tasks.append(task)
        print(
            "Task Added Successfully!"
        )
    elif choice == "2":
        print("\nTask List:")
        for task in tasks:
            print("-", task)
    elif choice == "3":
        print("Exiting App...")
        break
    else:
        print("Invalid Choice")

Output:

1. Add Task 2. View Tasks 3. Exit Enter Choice: 1 Enter Task: Learn Python Task Added Successfully!

Understanding the Code

1. Create Empty Task List


tasks = []

All tasks are stored inside a list.

2. Add Task


tasks.append(task)

Adds a new task to the list.

3. View Tasks


for task in tasks:

Displays all stored tasks.

4. Exit Application


break

Stops the program.

To-Do List App with Functions

Using functions makes the code cleaner and reusable.

Source Code:


tasks = []
def add_task():
    task = input(
        "Enter Task: "
    )
    tasks.append(task)
    print("Task Added")
def view_tasks():
    print("\nTasks:")
    for task in tasks:
        print("-", task)
while True:
    print("\n1. Add")
    print("2. View")
    print("3. Exit")
    choice = input("Choice: ")
    if choice == "1":
        add_task()
    elif choice == "2":
        view_tasks()
    elif choice == "3":
        break

Adding Delete Task Feature

Users should be able to remove tasks.

Source Code:


tasks = [
    "Learn Python",
    "Complete Project"
]
for index, task in enumerate(tasks):
    print(
        index + 1,
        task
    )
task_number = int(
    input(
        "Task Number to Delete: "
    )
)
tasks.pop(task_number - 1)
print("Task Deleted")

Output:

1 Learn Python
2 Complete Project
Task Number to Delete: 2
Task Deleted

Adding Update Task Feature

Users can modify existing tasks.

Source Code:


tasks = [
    "Learn Python"
]
task_number = int(
    input(
        "Task Number: "
    )
)
new_task = input(
    "Updated Task: "
)
tasks[task_number - 1] = new_task
print("Task Updated")

Mark Task as Completed

A useful feature in real-world applications.

Source Code:


tasks = [
    {"task": "Learn Python",
     "status": "Pending"}
]
tasks[0]["status"] = "Completed"
print(tasks)

Output:

[
{‘task’: ‘Learn Python’,
‘status’: ‘Completed’}
]

To-Do List App Using File Handling

Without file handling, tasks disappear after the program closes.

File handling allows permanent storage.

Save Tasks to File


tasks = [
    "Learn Python",
    "Build Project"
]
file = open(
    "tasks.txt",
    "w"
)
for task in tasks:
    file.write(
        task + "\n"
    )
file.close()

Read Tasks from File


file = open(
    "tasks.txt",
    "r"
)
tasks = file.readlines()
file.close()
for task in tasks:
    print(task.strip())

Complete To-Do List App

Features

  • Add Task
  • View Tasks
  • Update Task
  • Delete Task
  • Exit

Source Code


tasks = []
while True:
    print("\n===== TO-DO APP =====")
    print("1. Add Task")
    print("2. View Tasks")
    print("3. Update Task")
    print("4. Delete Task")
    print("5. Exit")
    choice = input("Choice: ")
    if choice == "1":
        task = input(
            "Enter Task: "
        )
        tasks.append(task)
    elif choice == "2":
        for index, task in enumerate(tasks):
            print(
                index + 1,
                task
            )
    elif choice == "3":
        task_num = int(
            input(
                "Task Number: "
            )
        )
        new_task = input(
            "New Task: "
        )
        tasks[
            task_num - 1
        ] = new_task
    elif choice == "4":
        task_num = int(
            input(
                "Delete Task Number: "
            )
        )
        tasks.pop(
            task_num - 1
        )
    elif choice == "5":
        break
    else:
        print("Invalid Choice")

Common Errors and Solutions

1. Invalid Task Number

Incorrect:


tasks.pop(10)

Error:

IndexError

Solution:


if task_number <= len(tasks):

Validate the task number.

2. Empty Task Input

Incorrect:


task = ""

Solution:

if task.strip():

Ensure tasks are not empty.

3. Forgetting to Save Tasks


Tasks disappear after exit.

Use files or databases for permanent storage.

Best Practices

Use Functions

Separate features into functions.

Validate Input

Prevent invalid values.

Handle Exceptions


try:
    pass
except:
    pass

Use Meaningful Names

Good:


task_list
task_number

Bad:


a
b

Project Enhancement Ideas

After completing the basic project, try adding:

  1. Task Priority Levels
  2. Due Dates
  3. Categories
  4. Search Tasks
  5. Task Sorting
  6. Dark Mode
  7. GUI Using Tkinter
  8. Database Integration (SQLite)
  9. User Authentication
  10. Cloud Synchronization

These features make the project more professional and suitable for portfolios.

Conclusion

The Python To-Do List App is an excellent beginner-to-intermediate project that teaches essential software development concepts through practical implementation.

It helps developers understand CRUD operations, file handling, functions, lists, loops, and user interaction.

Related Python Tutorials