0% found this document useful (0 votes)
23 views2 pages

Python Task Manager Program

This document contains a Python program for a task manager that allows users to add, complete, remove, and list tasks with their priorities. It defines functions for each action and includes a main loop to interact with the user. The program maintains a list of tasks and their statuses, providing feedback for each action performed.

Uploaded by

gandhijas
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)
23 views2 pages

Python Task Manager Program

This document contains a Python program for a task manager that allows users to add, complete, remove, and list tasks with their priorities. It defines functions for each action and includes a main loop to interact with the user. The program maintains a list of tasks and their statuses, providing feedback for each action performed.

Uploaded by

gandhijas
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

Python

# Task Manager Program

# create the empty list


tasks = []

# add a new task


def add_task(name, priority):
[Link]({"name": name, "priority": priority, "done": False})
print("Task '" + name + "' added!")

# mark a task as complete


def complete_task(name):
for task in tasks:
if task["name"] == name:
task["done"] = True
print("Task '" + name + "' was marked as complete. Yay!")
return
print("Task not found.")

# remove a task
def remove_task(name):
global tasks
# to make sure to reference the original tasks list created
new_tasks = []
for task in tasks:
if task["name"] != name:
new_tasks.append(task)
tasks = new_tasks
print("This task was removed: " + name)

# list all tasks with their status and priority


def list_tasks():
if not tasks:
print("Yay, you have no tasks to do!.")
else:
for task in tasks:
if task["done"]:
status = "✓"
else:
status = "✗"
print(status + " " + task["name"] + " (Priority: " +
task["priority"] + ")")
# main program loop
def task_manager():
while True:
# show the available actions
print("\nTask Manager: [add] [complete] [remove] [list] [exit]")
action = input("Enter action: ").strip().lower()

if action == "add":
name = input("Task you want to add: ")
priority = input("Priority (High/Medium/Low): ")
add_task(name, priority)

elif action == "complete":


name = input("Task you completed: ")
complete_task(name)

elif action == "remove":


name = input("Task you want removed: ")
remove_task(name)

elif action == "list":


list_tasks()

elif action == "exit":


print("Bye bye!")
break

else:
print("Thats not a command,\ try again!")
task_manager()

You might also like