promptdojo_
Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Final drill. Below is a function fetch that simulates an API call — it returns a (status_code, body) tuple. Write a function safe_fetch that:

  • Calls fetch(user_id).
  • If the status is 200, returns body["name"].
  • For any other status, returns the string "error".

Then the script will call safe_fetch(7) and safe_fetch(404) and print both. Expected output:

maya
error

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.