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
- Create an empty task list.
- Display menu options.
- Ask the user to choose an option.
- Perform the selected operation.
- Update the task list.
- Repeat until the user exits.
- 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:
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:
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:
Solution:
if task_number <= len(tasks):
Validate the task number.
2. Empty Task Input
Incorrect:
task = ""
Solution:
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:
- Task Priority Levels
- Due Dates
- Categories
- Search Tasks
- Task Sorting
- Dark Mode
- GUI Using Tkinter
- Database Integration (SQLite)
- User Authentication
- 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.