What is the Python equivalent for a case/switch statement? [duplicate]

Python 3.10 and above In Python 3.10, they introduced the pattern matching. Example from the Python documentation: def http_error(status): match status: case 400: return “Bad request” case 404: return “Not found” case 418: return “I’m a teapot” # If an exact match is not confirmed, this last case will be used if provided case _: … Read more

Multiple cases in switch statement

I guess this has been already answered. However, I think that you can still mix both options in a syntactically better way by doing: switch (value) { case 1: case 2: case 3: // Do Something break; case 4: case 5: case 6: // Do Something break; default: // Do Something break; }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)