Task management system with priorities
Python
Medium
classes
Task «Task management system with priorities»
Create a class `Task` with attributes: `title` (string), `priority` (integer from 1 to 5), `completed` (boolean, default `False`). Implement a class `TaskManager` that stores a list of tasks. The `TaskManager` class must have the following methods: `add_task(task)` — adds a task, `complete_task(title)` — marks a task as completed by its title (if the task is not found, print the message "Task not found"), `get_pending_tasks()` — returns a list of titles of incomplete tasks, sorted in descending order of priority (with equal priority, sorted alphabetically). Input data: an integer `n`, followed by `n` lines with commands. Commands: `"ADD <title> <priority>"`, `"COMPLETE <title>"`, `"PENDING"`. For the `PENDING` command, print the task titles on a single line, separated by commas. It is guaranteed that task titles are unique.
Input Format
Integer n (1 ≤ n ≤ 100). Then n lines, each line contains a command.
Output Format
For each PENDING command, a line is printed with the task names separated by commas. For COMPLETE with an unfound task, the message "Task not found" is printed.
Examples
Example 1
INPUT
5
1 2 3 2 1
OUTPUT
No PENDING command, so no output.
Example 2
INPUT
5
1 2 3 4 5
OUTPUT
No PENDING command, so no output.
main.py