What's new

Python Patulong po mga master sa project namin

Sure, I'd be happy to help you with your project!

Here's an example implementation of the to-do list manager in Python:

Python:
def display_menu():
    print("===== To-Do List Manager =====")
    print("1. Add Task")
    print("2. View Tasks")
    print("3. Mark Task as Completed")
    print("4. Exit")

def add_task(todo_list):
    task = input("Enter the task: ")
    todo_list.append([task, False])
    print("Task added successfully!")

def view_tasks(todo_list):
    print("===== Tasks =====")
    for i, task in enumerate(todo_list, 1):
        status = "Completed" if task[1] else "Not Completed"
        print(f"{i}. {task[0]} - {status}")

def mark_completed(todo_list):
    view_tasks(todo_list)
    task_num = int(input("Enter the task number to mark as completed: "))
    if task_num < 1 or task_num > len(todo_list):
        print("Invalid task number!")
    else:
        todo_list[task_num-1][1] = True
        print("Task marked as completed!")

def main():
    todo_list = [
        ["Buy groceries", False],
        ["Read a book", True],
        ["Write code", False],
    ]
    while True:
        display_menu()
        choice = input("Enter your choice (1-4): ")
        if choice == '1':
            add_task(todo_list)
        elif choice == '2':
            view_tasks(todo_list)
        elif choice == '3':
            mark_completed(todo_list)
        elif choice == '4':
            print("Exiting the program. Goodbye!")
            break
        else:
            print("Invalid choice!")

if __name__ == "__main__":
    main()

This implementation follows the requirements you provided. It uses a list (todo_list) to store the tasks, where each task is represented as a sublist containing the task description and its completion status.

The functions display_menu, add_task, view_tasks, mark_completed, and main are implemented as requested. The main function is the entry point of the program, and it runs in a loop until the user chooses to exit.

The program displays the menu options, gets the user's choice, and performs the corresponding action based on the selected option. The tasks are displayed with their completion status, and the user can mark a task as completed by entering the task number.

Input validation is implemented to handle unexpected user inputs gracefully, such as invalid task numbers.

I hope this helps! Let me know if you have any questions or need further assistance.
 
Back
Top