内容中心

2026年靠谱的缓释型包衣粉稳定供货厂家推荐-曲阜贝斯迪生物医药有限公司

# Simple Text-Based To-Do List Manager
def todo_manager():
    todo_list = []
    while True:
        print("\n===== To-Do List Manager =====")
        print("1. Add Task")
        print("2. View All Tasks")
        print("3. Mark Task as Done")
        print("4. Delete Task")
        print("5. Exit")
        choice = input("Enter your choice (1-5): ")

        if choice == '1':
            task = input("Enter the task description: ")
            todo_list.append({"task": task, "done": False})
            print(f"Task '{task}' added successfully!")
        elif choice == '2':
            if not todo_list:
                print("Your to-do list is empty!")
            else:
                print("\nYour Tasks:")
                for idx, item in enumerate(todo_list, 1):
                    status = "[Done]" if item["done"] else "[Not Done]"
                    print(f"{idx}. {status} {item['task']}")
        elif choice == '3':
            if not todo_list:
                print("No tasks to mark as done!")
            else:
                try:
                    task_num = int(input("Enter the task number to mark as done: ")) -1
                    if 0 <= task_num < len(todo_list):
                        todo_list[task_num]["done"] = True
                        print("Task marked as done!")
                    else:
                        print("Invalid task number!")
                except ValueError:
                    print("Please enter a valid number!")
        elif choice == '4':
            if not todo_list:
                print("No tasks to delete!")
            else:
                try:
                    task_num = int(input("Enter the task number to delete: ")) -1
                    if 0 <= task_num < len(todo_list):
                        deleted = todo_list.pop(task_num)
                        print(f"Task '{deleted['task']}' deleted successfully!")
                    else:
                        print("Invalid task number!")
                except ValueError:
                    print("Please enter a valid number!")
        elif choice == '5':
            print("Exiting To-Do List Manager. Goodbye!")
            break
        else:
            print("Invalid choice! Please enter a number between 1 and 5.")

if __name__ == "__main__":
    todo_manager()

This simple text-based To-Do List Manager is a practical Python project that demonstrates core programming concepts like loops, conditional logic, user input handling, and structured data storage. Its key features include adding task descriptions, viewing tasks with clear status indicators (Done/Not Done), updating task completion statuses, deleting unwanted tasks, and a user-friendly exit option. Common uses for this tool include personal daily task planning, serving as a beginner-friendly introduction to interactive CLI application development, and acting as a foundation for more advanced versions (such as adding persistent storage via files or a database, or a graphical interface) to meet larger productivity needs.

曲阜贝斯迪生物医药有限公司

曲阜贝斯迪生物医药有限公司



作者声明:本文包含人工智能生成内容。

在线客服

在线留言
您好,很高兴为您服务,可以留下您的电话或微信吗?