0

I'm trying to reproduce an example that I've found here. I guess the match function is not recognised:

def http_error(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"

  File "<ipython-input-151-1f275f95d012>", line 2
    match status:
          ^
SyntaxError: invalid syntax

I thought maybe the match function is missing, so I did import re and then replaced the match with re.match, but that also didn't work.

Any idea what's going wrong?

0 Answers0