gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
write me a simple to do list in python
- User
write me a simple to do list in python
- Assistant
Sure! Here's a simple to-do list program in Python where you can add, view, and delete tasks.
tasks = [] def add_task(): task = input("Enter a task: ") tasks.append(task) print("Task added successfully!") def view_tasks(): if tasks: print("Tasks:") for i, task in enumerate(tasks, start=1): print(f"{i}. {task}") else: print("No tasks found.") def delete_task(): view_tasks() if tasks: task_num = int(input("Enter the task number to delete: ")) if 1 <= task_num <= len(tasks): del tasks[task_num - 1] print("Task deleted successfully!") else: print("Invalid task number.") else: print("No tasks found.") def main(): while True: print("\n--- To-Do List ---") print("1. Add task") print("2. View tasks") print("3. Delete task") print("4. Exit") choice = input("Enter your choice (1-4): ") if choice == "1": add_task() elif choice == "2": view_tasks() elif choice == "3": delete_task() elif choice == "4": break else: print("Invalid choice. Please try again.") if __name__ == "__main__": main()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.