Command Palette

Search for a command to run...

Hectal
Phase 2: Control Flow
Python · Exercise 6 of 6 Previous
Beginner

Name an HTTP status with match

Use a match statement on the variable status to set the variable message: "OK" for 200, "Redirect" for 301 or 302, "Not found" for 404, "Server error" for 500, 502 or 503, and "Unknown" for anything else.

Then print Status followed by the status, a colon and the message, such as Status 404: Not found.

What Check tests

  1. 404 gives Not found
  2. 302 gives Redirect
  3. 502 gives Server error
  4. 418 gives Unknown
  5. 200 gives OK and 503 gives Server error
  6. Your code uses match
  7. The program prints Status 404: Not found

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.