0% found this document useful (0 votes)
20 views1 page

Todo App - Py

The document is a Python script for a simple to-do list application. It allows users to add, view, and remove tasks from a list through a menu-driven interface. The application continues to run until the user chooses to exit.

Uploaded by

dartk687
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Todo App - Py

The document is a Python script for a simple to-do list application. It allows users to add, view, and remove tasks from a list through a menu-driven interface. The application continues to run until the user chooses to exit.

Uploaded by

dartk687
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

# todo_app.

py

tasks = []

def show_menu():
print("\n--- To-Do List ---")
print("1. Add Task")
print("2. View Tasks")
print("3. Remove Task")
print("4. Exit")

def add_task():
task = input("Enter task: ")
tasks.append(task)
print("Task added!")

def view_tasks():
if not tasks:
print("No tasks yet.")
else:
for i, task in enumerate(tasks, 1):
print(f"{i}. {task}")

def remove_task():
view_tasks()
try:
task_num = int(input("Enter task number to remove: "))
removed = tasks.pop(task_num - 1)
print(f"Removed task: {removed}")
except (IndexError, ValueError):
print("Invalid task number.")

while True:
show_menu()
choice = input("Choose an option (1-4): ")

if choice == "1":
add_task()
elif choice == "2":
view_tasks()
elif choice == "3":
remove_task()
elif choice == "4":
print("Goodbye!")
break
else:
print("Invalid choice.")

You might also like