Use Python to Create a To-Do App Step-by-Step

A Beginner-Friendly Project for Learning Python

If you're new to programming and want a hands-on project to practice your Python skills, creating a To-Do List App is a great start. It teaches basic concepts such as variables, functions, file handling, conditionals, and loops — all while building something useful and practical.

Use Python to Create a To-Do App Step-by-Step

In this step-by-step guide, you’ll build a simple terminal-based To-Do app using core Python, and by the end, you’ll understand how to expand it further with GUI or web frameworks.

Why Build a To-Do App in Python?

  • It's beginner-friendly.
     
  • It covers essential Python features.
     
  • It's practical — you’ll use it daily.
     
  • It helps you learn file operations.
     
  • You can later upgrade it to a full web or desktop app.

Project Overview

We’ll build a terminal-based to-do list with the following features:

  • Add a new task
     
  • View all tasks
     
  • Mark a task as complete
     
  • Delete a task
     
  • Save tasks to a file (so they persist between runs)
     

Step 1: Project Setup

You only need:

  • Python (version 3.6+)
     
  • A text editor (VS Code, Sublime, Notepad++)
     
  • Command line or terminal
     

Create a folder:

bash

CopyEdit

mkdir todo-app

cd todo-app

Inside this folder, create a file:

bash

CopyEdit

touch todo.py

Step 2: Structure the Program

We’ll use a simple dictionary list to manage tasks. Let’s plan:

  • tasks.txt to save data persistently.
     
  • A list of dictionaries with task, completed fields.
     

Step 3: Load and Save Tasks

First, define how tasks will be saved and loaded from a file.

Code:

python

CopyEdit

Copy Code

import os

import json

FILE_NAME = “tasks.txt”

def load_tasks():

    if not os.path.exists(FILE_NAME):

        return []

    with open(FILE_NAME, 'r') as file:

        return json.load(file)

def save_tasks(tasks):

    with open(FILE_NAME, 'w') as file:

        json.dump(tasks, file, indent=4)

Explanation:

  • We’re using JSON for easy read/write of task lists.
     
  • tasks.txt will hold the list of tasks in JSON format.

Step 4: Display the Menu

We want to show options to the user every time they open the app.

Code:

python

CopyEdit

Copy Code

def show_menu():

    print("\n=== TO-DO LIST MENU ===")

    print("1. View Tasks")

    print("2. Add Task")

    print("3. Mark Task as Completed")

    print("4. Delete Task")

    print("5. Exit")

Step 5: View All Tasks

Display tasks with status.

Code:

python

CopyEdit

Copy Code

def view_tasks(tasks):

    if not tasks:

        print("No tasks found.")

        return

    for index, task in enumerate(tasks):

        status = "✔" if task['completed'] else "❌"

        print(f"{index + 1}. [{status}] {task['task']}")

Step 6: Add a New Task

Code:

python

CopyEdit

Copy Code

def add_task(tasks):

    task_name = input("Enter the task: ")

    tasks.append({'task': task_name, 'completed': False})

    save_tasks(tasks)

    print("Task added successfully!")

Step 7: Mark a Task as Completed

Code:

python

CopyEdit

Copy Code

def mark_completed(tasks):

    view_tasks(tasks)

    try:

        choice = int(input("Enter task number to mark as completed: ")) - 1

        if 0 <= choice < len(tasks):

            tasks[choice]['completed'] = True

            save_tasks(tasks)

            print("Task marked as completed.")

        else:

            print("Invalid task number.")

    except ValueError:

        print("Please enter a valid number.")

Step 8: Delete a Task

Code:

python

CopyEdit

Copy Code

def delete_task(tasks):

    view_tasks(tasks)

    try:

        choice = int(input("Enter task number to delete: ")) - 1

        if 0 <= choice < len(tasks):

            deleted = tasks.pop(choice)

            save_tasks(tasks)

            print(f"Deleted task: {deleted['task']}")

        else:

            print("Invalid task number.")

    except ValueError:

        print("Please enter a valid number.")

Step 9: Main App Loop

Now that we have all the building blocks, let’s combine them into a loop.

Code:

python

CopyEdit

Copy Code

def main():

    tasks = load_tasks()

    while True:

        show_menu()

        choice = input("Choose an option (1-5): ")

        if choice == '1':

            view_tasks(tasks)

        elif choice == '2':

            add_task(tasks)

        elif choice == '3':

            mark_completed(tasks)

        elif choice == '4':

            delete_task(tasks)

        elif choice == '5':

            print("Exiting... Have a productive day!")

            break

        else:

            print("Invalid choice. Try again.")         

if __name__ == "__main__":

    main()

Sample Output:

vbnet

CopyEdit

=== TO-DO LIST MENU ===

1. View Tasks

2. Add Task

3. Mark Task as Completed

4. Delete Task

5. Exit

Choose an option (1-5): 2

Enter the task: Complete Python project

Task added successfully!

=== TO-DO LIST MENU ===

1. View Tasks

How It Works Behind the Scenes

  • tasks.txt is used to persist data using JSON.
     
  • A list of dictionaries stores each task with its status.
     
  • Every time the user performs an operation, the file is updated.

Ideas to Upgrade This App

Once you understand this terminal version, here are upgrade ideas:

1. Add Due Dates

Add a due_date field to tasks:

python

CopyEdit

Copy Code

tasks.append({'task': task_name, 'completed': False, 'due_date': '2025-08-05'})

2. Use a GUI Framework

Use Tkinter or PyQt to make a desktop app with buttons and checkboxes.

3. Use a Database

Use SQLite to store tasks instead of a text file.

4. Convert It to a Web App

Use Flask or Django to convert this into a fully working web app.

Why This Project Is Great for Beginners

BenefitWhat You Learn
File HandlingReading and writing with Python
JSONData serialization and parsing
Functions and LoopsModular thinking and program structure
User Input & ValidationInteracting with users safely
Project StructureWorking with real-world logic

Frequently Asked Questions

Q: Can I make this app in other languages?

Yes, you can build the same app using JavaScript (Node.js), C++, Java, or any language that supports I/O and logic control.

Q: How to run this app repeatedly?

Just run:

bash

CopyEdit

python todo.py

The tasks are saved between sessions using the tasks.txt file.

Q: How to make it available on my phone or online?

You can use Flask to create a web version and host it on platforms like RenderPythonAnywhere, or Heroku.

Final Thoughts

Building a simple To-Do app in Python is more than just writing code. It’s your gateway into learning how real applications work — from user input to data storage. By following this project, you've already used file I/O, data structures, loops, and conditional logic.

This small but powerful project is the perfect foundation for larger apps in the future.

Ready to Build More Real-World Projects?

👉 Learn Python with real hands-on projects at Uncodemy. Their Python Programming Course covers beginner to advanced concepts with live classes, mentorship, and career support.

Take your skills from simple scripts to full applications — start learning today.

Placed Students

Our Clients

Partners

...

Uncodemy Learning Platform

Uncodemy Free Premium Features

Popular Courses