promptdojo_

Status codes and error handling — what AI's API calls do when the wire blinks — step 8 of 9

Write a function classify(status) that takes an HTTP status code and returns one of these strings:

  • "success" for any 2xx (200-299)
  • "client-error" for any 4xx (400-499)
  • "server-error" for any 5xx (500-599)
  • "other" for anything else (including 1xx and 3xx)

Then loop over a list of test codes and print the result of each.

Expected output:

success
client-error
server-error
other
other

full-screen editor opens — close anytime to keep reading.