Home Tutorials Python Programs To-Do List
To-Do List

To-Do List


Topic: Simple Console To-Do List Tracker

Description: A program utilizing array collections that acts as a console tracking interface, enabling dynamic options for listing out saved items, appending new item operations, and clearing completed criteria arrays.

Why: This example illustrates practical architectural applications of **Data Lists & Collections**. It teaches students how arrays change structural length state parameters dynamically in direct response to operational input triggers.


Program Code

def manage_todo_system():
    todo_list = []
    
    while True:
        print("\n--- TASKS DIRECTORY SYSTEM ---")
        print("1. View Tasks")
        print("2. Add New Task")
        print("3. Remove Task")
        print("4. Exit Directory")
        
        choice = input("\nSelect operation code (1-4): ").strip()
        
        if choice == "1":
            if not todo_list:
                print("\nYour directory backlog is empty.")
            else:
                print("\nActive System Tasks:")
                for index, task in enumerate(todo_list, start=1):
                    print(f"  {index}. {task}")
                    
        elif choice == "2":
            new_task = input("Enter the text detail for task: ").strip()
            if new_task:
                todo_list.append(new_task)
                print(f"Success: '{new_task}' added inside backlog array.")
                
        elif choice == "3":
            if not todo_list:
                print("\nNo records present to remove from archive.")
            else:
                try:
                    task_num = int(input("Enter task index number to clear: "))
                    removed = todo_list.pop(task_num - 1)
                    print(f"Cleared Record: '{removed}' safely dropped.")
                except (ValueError, IndexError):
                    print("Error: Invalid entry reference position.")
                    
        elif choice == "4":
            print("\nShutting down core tracker. Application terminated.")
            break
        else:
            print("Invalid Code Selection. Enter 1 to 4.")

# Run list environment
manage_todo_system()

Expected Console Output Examples

--- TASKS DIRECTORY SYSTEM ---
1. View Tasks
2. Add New Task
3. Remove Task
4. Exit Directory

Select operation code (1-4): 2
Enter the text detail for task: Setup Laravel Backend

Success: 'Setup Laravel Backend' added inside backlog array.

Core Syntax & Concept Breakdown

  • Collection Enumeration (enumerate()): This built-in function wraps an iterable dataset index configuration, returning both the position tracker integer and data properties concurrently.
  • Array Shifting Methods (append() & pop()): .append() adds an item to the end of a list, whereas .pop() removes and returns an element at a specific index location.

🏋️ Test Yourself With Exercises

Take our quiz on To-Do List to test your knowledge.

Browse Quizzes »