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

Todo List

This document provides a simple console-based To-Do List application in Python. It includes functions to show the menu, display tasks, add tasks, and remove tasks. The program runs in a loop until the user chooses to exit.

Uploaded by

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

Todo List

This document provides a simple console-based To-Do List application in Python. It includes functions to show the menu, display tasks, add tasks, and remove tasks. The program runs in a loop until the user chooses to exit.

Uploaded by

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

# Simple To-Do List in Python (Console-based)

tasks = []

def show_menu():
print("\nTo-Do List Menu:")
print("1. Show Tasks")
print("2. Add Task")
print("3. Remove Task")
print("4. Exit")

def show_tasks():
if not tasks:
print("No tasks to show.")
else:
print("Tasks:")
for i, task in enumerate(tasks, start=1):
print(f"{i}. {task}")

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

def remove_task():
show_tasks()
try:
index = int(input("Enter task number to remove: ")) - 1
if 0 <= index < len(tasks):
removed = tasks.pop(index)
print(f"Removed: {removed}")
else:
print("Invalid task number.")
except ValueError:
print("Please enter a valid number.")

while True:
show_menu()
choice = input("Enter your choice: ")
if choice == '1':
show_tasks()
elif choice == '2':
add_task()
elif choice == '3':
remove_task()
elif choice == '4':
print("Exiting...")
break
else:
print("Invalid choice. Try again.")

You might also like