Beautiful Task Organization

As the new project manager in a fast-growing tech company, you're handed the responsibility of managing a complex and diverse task list. This list, however, is not a simple flat list but rather a hierarchical one, where each task may potentially have multiple subtasks associated with it. The task and subtasks are represented in a nested list where each item is either a single task (as a string) or a list of subtasks.
Your challenge is to write a recursive function that will navigate this hierarchy and print all the tasks and subtasks in the order they appear in the nested list. For readability and easier understanding, each subtask should be indented by a tab more than its parent task.
The input will be a nested list of n tasks and subtasks. Each item in the list is either a task (as a string) or another list, which represents subtasks. You can load the list with eval(input()) or json.loads(...).
The program should print all tasks and subtasks as strings, in the order they appear in the list. Each subtask should be indented by a tab more than its parent task.
Input
Output
["Task 1", ["Subtask 1.1", "Subtask 1.2", ["Subtask 1.2.1", "Subtask 1.2.2"], "Subtask 1.3"], "Task 2", ["Subtask 2.1"]]
Task 1 Subtask 1.1 Subtask 1.2 Subtask 1.2.1 Subtask 1.2.2 Subtask 1.3 Task 2 Subtask 2.1
Note: In the output, each tab is represented as a \t character. Also, the order of tasks and subtasks in the output should follow their order in the input nested list.
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue