Medium
Run Code When a Task Finishes
Write
async def work(x) returning x × x. Create a task for each input number and attach add_done_callback that appends task.result() to a list. Await all tasks, then print the list sorted.Input
Integers separated by spaces.
Output
A Python list.
Sample 1
Input
3 1 2
Output
[1, 4, 9]
Sample 2
Input
5
Output
[25]
Output appears here