Python · Exercise 1 of 6Next
Intermediate
Fetch many pages at once with gather
fake_fetch(name) pretends to download a page and returns "page:<name>". Write async def fetch_all(names) that fetches all the names at the same time with asyncio.gather and returns the list of pages in the same order as names.
An empty list gives []. The program should print ['page:a', 'page:b', 'page:c'].
What Check tests
fetch_all(["a", "b", "c"])returns the pages in orderfetch_all([])returns an empty list- The four fetches overlap (all four in flight at once)
- The program prints the three pages
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.