Command Palette

Search for a command to run...

Hectal
Phase 12: Concurrency and Async
Python · Exercise 2 of 6 PreviousNext
Intermediate

Collect results and errors without crashing

risky(name) returns name.upper(), but raises ValueError for names that start with "bad". Write async def collect_all(names) that runs risky for every name together and returns one string per name, in order: "ok:<RESULT>" for a success or "error:<message>" for a failure.

It must never raise. For example ["a", "bad1", "c"] gives ['ok:A', 'error:bad1 is not allowed', 'ok:C'].

What Check tests

  1. Mixed names give ok and error strings in order
  2. All good names give only ok strings
  3. All bad names do not raise
  4. An empty list gives an empty list

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.