# To Do List Creator in Python
tasks = []
while True:
action = input("Enter 'add', 'remove', or 'show': ")
if action == "add":
task = input("Enter task: ")
tasks.append(task)
elif action == "remove":
tasks.pop(0) if tasks else print("No tasks!")
elif action == "show":
print(tasks)
This Python program is a simple task manager using a list and a while loop to continuously take user input. It allows users to add, remove, and view tasks dynamically.
- Task Storage: An empty list
tasks
is initialized to store tasks. - User Input Loop: The program runs indefinitely using
while True
, prompting the user to enter an action:'add'
,'remove'
, or'show'
. - Adding a Task: If the user enters
"add"
, they are prompted to input a task, which is then appended to thetasks
list. - Removing a Task: If the user enters
"remove"
, the program removes the first task (tasks.pop(0)
). If the list is empty, it prints"No tasks!"
to prevent errors. - Showing Tasks: If the user enters
"show"
, the program prints the current list of tasks.
Features:
- FIFO (First-In-First-Out) Removal: Tasks are removed in the order they were added, like a queue.
- Error Handling: It prevents errors by checking if the list is empty before removing a task.
- Continuous Execution: The program runs indefinitely until manually stopped (Ctrl+C).
Possible Improvements:
- Allow users to exit the loop.
- Add task numbering for better management.
- Provide more removal options (e.g., remove specific tasks).