I’m trying to make a reminder code:
import json
class Task:
def init(self, title, description, priority):
self.title = title
self.description = description
self.priority = priority
self.status = “Pending”
class TaskManager:
def init(self):
self.tasks =
def add_task(self, task):
self.tasks.append(task)
print(f"Task '{task.title}' added successfully.")
def complete_task(self, title):
for task in self.tasks:
if task.title == title:
task.status = "Completed"
print(f"Task '{title}' marked as completed.")
return
print(f"Task '{title}' not found.")
def list_tasks(self):
if not self.tasks:
print("No tasks found.")
return
print("List of Tasks:")
for task in self.tasks:
print(f"Title: {task.title}")
print(f"Description: {task.description}")
print(f"Priority: {task.priority}")
print(f"Status: {task.status}")
print()
def load_tasks_from_file(filename):
try:
with open(filename, ‘r’) as file:
tasks_data = json.load(file)
tasks = [Task(task[‘title’], task[‘description’], task[‘priority’]) for task in tasks_data]
return tasks
except FileNotFoundError:
return
def save_tasks_to_file(tasks, filename):
tasks_data = [{‘title’: task.title, ‘description’: task.description, ‘priority’: task.priority} for task in tasks]
with open(filename, ‘w’) as file:
json.dump(tasks_data, file)
def main():
while True:
task_manager = TaskManager()
task_manager.tasks = load_tasks_from_file("tasks.json")
while True:
print("Task Management System")
print("1. Add Task")
print("2. Complete Task")
print("3. List Tasks")
print("4. Quit")
choice = input("Enter your choice: ")
if choice == '1':
title = input("Enter task title: ")
description = input("Enter task description: ")
priority = input("Enter task priority (High/Medium/Low): ")
task_manager.add_task(Task(title, description, priority))
elif choice == '2':
title = input("Enter the title of the task to mark as complete: ")
task_manager.complete_task(title)
elif choice == '3':
task_manager.list_tasks()
elif choice == '4':
save_tasks_to_file(task_manager.tasks, "tasks.json")
print("Exiting program.")
return
else:
print("Invalid choice. Please enter a valid option.")
continue_choice = input("Do you want to continue? (yes/no): ")
if continue_choice.lower() != 'yes':
save_tasks_to_file(task_manager.tasks, "tasks.json")
print("Exiting program.")
return
if name == “main”:
while True:
main()
resume_choice = input("Do you want to resume the Task Management System? (yes/no): ")
if resume_choice.lower() != ‘yes’:
print(“Exiting program.”)
main()
but I just can’t seem to make the “completed” task go away when I list my tasks please help I’m new