You can define a default case in Python. For this you use a wild card (_). The following code demonstrates it:

x = "hello"
match x:
    case "hi":
        print(x)
    case "hey":
        print(x)
    case _:
        print("not matched")
Answer from Prince Hamza on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-match-case-statement
Python Match Case Statement - GeeksforGeeks
December 11, 2025 - Introduced in Python 3.10, the match case statement offers a powerful mechanism for pattern matching in Python. It allows us to perform more expressive and readable conditional checks.
🌐
Python.org
discuss.python.org › ideas
Use "case else" instead of "case _" in match statement - Ideas - Discussions on Python.org
September 16, 2024 - UPD: Probably it not worth it. Rationale Wildcard pattern case _ treats legal variable name _ specially (soft keyword). Syntax case _ has readability issues. It would be much readable if keyword else appear somewhere. Proposed syntax case else with if guard denied.
Discussions

Is it "right" to use the match/case statement rather than if/else when you just want to check certain conditions?
For those who haven't dug in yet, I can thoroughly recommend Raymond Hettinger's video on structural pattern matching - great content, and also explains some of the unexpected aspects. More on reddit.com
🌐 r/learnpython
18
7
December 11, 2024
Should I use match case instead of if else
Use match case when you need structural pattern matching. If you don't know what that is, read https://peps.python.org/pep-0622/ and https://nedbatchelder.com/blog/202312/realworld_matchcase.html More on reddit.com
🌐 r/learnpython
18
17
April 7, 2024
Match/case syntax
In the dark ages when I used to code in vbScript I found this form of the select/case to be clearer than repeated if/else if blocks. I there a form of the new match/case in Python that accomplishes the same thing? I am aware that there are easier ways of coding this particular example but the ... More on discuss.python.org
🌐 discuss.python.org
0
October 24, 2022
Anyone used match case yet?
Last I used match/case, I used it as a replacement to isinstance. match/case + dataclasses + "mypy static typing" work together to help me get exhaustive type-casing and destructuring. More on reddit.com
🌐 r/Python
82
80
January 27, 2024
🌐
Reddit
reddit.com › r/learnpython › is it "right" to use the match/case statement rather than if/else when you just want to check certain conditions?
r/learnpython on Reddit: Is it "right" to use the match/case statement rather than if/else when you just want to check certain conditions?
December 11, 2024 -

I can't say I fully understand the match/case statement yet, but I know a part of it involves more than just simple pattern matching. I know that the expression in the match statement, for example, actually runs and creates a result, such as an object if it's a call to a class.

So I'm wondering, if I don't want to do all that and just want to use it as a cleaner version of if/else, is this considered Pythonic, or is it overkill?

For example:

if some_value == True and some_other == 1:
    do something
elif some_value == False and some_other == 1:
    do something else
etc etc etc

or:

match (some_value, some_other):
    case (True, 1):
        do something
    case (False, 1):
        do something else
    etc etc etc

First off, I *think* I'm getting the syntax correct! Second, I'm not actually creating any values with the expressions, so it feels like a glorified if/else construct, just cleaner looking.

Is this a valid use of match/case?

Thanks!

🌐
W3Schools
w3schools.com › python › python_match.asp
Python Match
The match statement is used to perform different actions based on different conditions. Instead of writing many if..else statements, you can use the match statement. The match statement selects one of many code blocks to be executed. match ...
🌐
Stackademic
blog.stackademic.com › python-match-case-statement-63d01477e1c0
Python Match-Case Statement. Starting from Python 3.10, the Python… | by Caner Uysal | Stackademic
June 12, 2024 - The match statement allows you to perform different actions based on a set of patterns that match the values or data structures of variables. The match statement uses case statements to specify the cases where data structures or patterns match.
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.3 documentation
December 11, 2025 - For this last case, many people use the ellipsis literal ... instead of pass. This use has no special meaning to Python, and is not part of the language definition (you could use any constant expression here), but ... is used conventionally as a placeholder body as well. See The Ellipsis Object. A match statement takes an expression and compares its value to successive patterns given as one or more case blocks.
Find elsewhere
🌐
Codefinity
codefinity.com › blog › Match-case-Operators-in-Python
Match-case Operators in Python
They are a new way to implement conditional statements that are more efficient and convenient than if-elif-else statements. Match-case operators work by iterating over all possible values of a variable.
🌐
Tutorialspoint
tutorialspoint.com › home › python › python match case statement
Python Match Case Statement
February 21, 2009 - With the release of Python 3.10, a pattern matching technique called match-case has been introduced, which is similar to the switch-case construct available in C/C++/Java etc. Its basic use is to compare a variable against one or more values.
🌐
DataCamp
datacamp.com › tutorial › python-switch-case
Python Switch Case Statement: A Beginner's Guide | DataCamp
December 6, 2024 - No, match-case is available only in Python 3.10 and later. For earlier versions, you can use if-elif-else or dictionary mapping to achieve similar functionality.
🌐
Analytics Vidhya
analyticsvidhya.com › home › what is match case statement in python?
What is Match Case Statement in Python? - Analytics Vidhya
May 29, 2024 - age = 30 if age < 18: print("Minor") else: if 18 <= age < 65: print("Adult") else: print("Senior") The above code can be rewritten using a match case statement as shown in example above. When using match case statements in Python, developers often encounter common mistakes and pitfalls related to parameter parsing, sequence patterns, and unpacking.
🌐
Python Snacks
pythonsnacks.com › p › python-match-case-statements-switch-statements
Python's match/case Statements: The Equivalent of Switch Statements
June 18, 2025 - def http_status(code): if code == 200: return "OK" elif code == 404: return "Not Found" elif code == 500: return "Server Error" else: return "Unknown" With match/case, this becomes more readable and concise: def http_status(code): match code: case 200: return "OK" case 404: return "Not Found" case 500: return "Server Error" case _: return "Unknown"
🌐
Medium
medium.com › cloud-for-everybody › python-match-case-statement-a-simple-yet-powerful-alternative-to-if-elif-else-69ba14194b5c
Python Match-Case Statement: A Simple Yet Powerful Alternative to If-Elif-Else
December 7, 2025 - def track_order(status): if status == "ordered": print("Your order has been placed.") elif status == "preparing": print("The restaurant is preparing your food.") elif status == "out_for_delivery": print("Your food is on the way!") elif status == "delivered": print("Enjoy your meal!") elif status == "cancelled": print("Your order has been cancelled.") else: print("Unknown order status.") track_order("out_for_delivery") # Output: Your food is on the way!
🌐
edSlash
edslash.com › home › python tutorials – learn with edslash › match case statement in python
match case statement in Python - edSlash
September 22, 2024 - In summary, match case focuses on pattern-based cases, while if-else handles broader conditions with flexibility.
🌐
Scaler
scaler.com › home › topics › python match-case statement
Python Match-Case Statement - Scaler Topics
January 2, 2024 - Python 3.10 introduces the match-case statement, enhancing code readability through simplified conditional branching. This statement enables pattern matching against values, offering a more streamlined approach than traditional if-elif-else blocks.
🌐
Metaschool
metaschool.so › home › answers › python switch case guide: using match and case statements simplified
Python Switch Case Guide: Using Match and Case Statements Simplified
January 16, 2025 - Python uses match and case statements to imitate the functionality of a Switch Case statement. It offers a more organized alternative to if, elif, and else for handling multiple conditions.
🌐
Geek Python
geekpython.in › match-case-in-python
How To Use Match Case Statement For Pattern Matching In Python
August 15, 2023 - Before the proposal or release of the match case statement in Python, the if-else statement is primarily used for pattern matching or performing conditional operations.
🌐
Plain English Westminster
benhoyt.com › writings › python-pattern-matching
Structural pattern matching in Python 3.10
However, as the rationale PEP points out, it’s better thought of as a “generalized concept of iterable unpacking”. Many people have asked for a switch in Python over the years, though I can see why that has never been added. It just doesn’t provide enough value over a bunch of if ... elif statements to pay for itself. The new match ... case feature provides the basics of switch, plus the “structural” matching part – and some.
🌐
Python.org
discuss.python.org › python help
Match/case syntax - Python Help - Discussions on Python.org
October 24, 2022 - In the dark ages when I used to code in vbScript I found this form of the select/case to be clearer than repeated if/else if blocks. I there a form of the new match/case in Python that accomplishes the same thing? I am aware that there are easier ways of coding this particular example but the beauty of this form is that the conditions in the case clauses do not have to be related. select case True case distance