Staying organized is key for students, developers, and anyone managing tasks. In this tutorial, we’ll build a simple To-Do List in Python that allows you to add, view, and delete tasks directly from the console. It’s a perfect beginner-friendly project and a great way to practice Python programming.
Prerequisites
-Basic knowledge of Python
-Python installed on your computer (or use Replit to run the code online)
Step 1: The Complete Code
import datetime
List to store tasks
tasks = []
def show_menu():
print("\n=== Student To-Do App ===")
print("1. Add a task")
print("2. Show all tasks")
print("3. Show today's tasks")
print("4. Delete a task")
print("5. Quit")
def add_task():
title = input("Task name: ")
priority = input("Priority (high/medium/low): ").lower()
deadline = input("Deadline (YYYY-MM-DD, leave empty if none): ")
if deadline:
try:
deadline = datetime.datetime.strptime(deadline, "%Y-%m-%d").date()
except ValueError:
print(" Wrong date format! Example: 2025-09-14")
return
else:
deadline = None
task = {"title": title, "priority": priority, "deadline": deadline}
tasks.append(task)
print(f" Task '{title}' added successfully!")
def show_all_tasks():
if not tasks:
print(" No tasks found.")
return
print("\n--- All Tasks ---")
for i, task in enumerate(tasks, start=1):
deadline_str = task["deadline"].strftime("%Y-%m-%d") if task["deadline"] else "No deadline"
print(f"{i}. {task['title']} | Priority: {task['priority']} | Deadline: {deadline_str}")
def show_today_tasks():
today = datetime.date.today()
today_tasks = [t for t in tasks if t["deadline"] == today]
if not today_tasks:
print(" No tasks for today!")
return
print("\n--- Today's Tasks ---")
for i, task in enumerate(today_tasks, start=1):
print(f"{i}. {task['title']} | Priority: {task['priority']}")
def delete_task():
show_all_tasks()
if not tasks:
return
try:
index = int(input("Task number to delete: ")) - 1
if 0 <= index < len(tasks):
removed = tasks.pop(index)
print(f" Task '{removed['title']}' deleted.")
else:
print(" Invalid number.")
except ValueError:
print(" Invalid input. Enter a number.")
Main program
while True:
show_menu()
choice = input("Your choice: ")
if choice == "1":
add_task()
elif choice == "2":
show_all_tasks()
elif choice == "3":
show_today_tasks()
elif choice == "4":
delete_task()
elif choice == "5":
print(" Thanks for using Student To-Do App. Good luck!")
break
else:
print(" Invalid choice, try again.")
Step 2: How It Works
1/ Add a task: Enter the task name, priority, and optional deadline.
2/ Show all tasks: See a list of all your tasks with their priority and deadline.
3/ Show today’s tasks: Only display tasks due today.
4/ Delete a task: Remove a task by its number in the list.
5/ Quit: Exit the application.
Step 3: Possible Improvements
-Add file saving so tasks remain after closing the program.
-Create a GUI version using Tkinter or Streamlit.
-Add a Pomodoro timer to help stay focused.
Conclusion
This simple Python project helps you practice basic Python concepts like lists, dictionaries, loops, and user input. You can expand it into a bigger project, like a fully-featured To-Do App or a study planner.
Try it yourself, modify it, and share your version with the CoderLegion community!