{"id":8291,"date":"2024-09-11T09:32:54","date_gmt":"2024-09-11T09:32:54","guid":{"rendered":"https:\/\/metaschool.so\/articles\/?p=8291"},"modified":"2025-01-16T08:29:13","modified_gmt":"2025-01-16T08:29:13","slug":"python-switch-case","status":"publish","type":"post","link":"https:\/\/metaschool.so\/articles\/python-switch-case\/","title":{"rendered":"Python Switch Case Guide: Using Match and Case Statements Simplified"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_56_1 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/metaschool.so\/articles\/python-switch-case\/#What_is_a_Switch_Case_Statement\" title=\"What is a Switch Case Statement?\">What is a Switch Case Statement?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/metaschool.so\/articles\/python-switch-case\/#Pythons_Match_and_Case\" title=\"Python&#8217;s Match and Case\">Python&#8217;s Match and Case<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/metaschool.so\/articles\/python-switch-case\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/metaschool.so\/articles\/python-switch-case\/#FAQs\" title=\"FAQs\">FAQs<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>The switch case statement simplifies the decision-making process in programming by offering a more organized way to handle multiple conditions compared to Python&#8217;s <a href=\"https:\/\/www.w3schools.com\/python\/gloss_python_elif.asp\" target=\"_blank\" rel=\"noopener\"><code>if<\/code>, <code>elif<\/code><\/a>, and <code>else<\/code> structure.<\/p>\n\n\n\n<p>In Python, the <code>if<\/code> statement runs code if a condition is true, otherwise it runs code under <code>else<\/code>. Multiple conditions can be handled with <code>elif<\/code> statements. However, this approach can become cumbersome and confusing with numerous <code>elif<\/code> conditions and indentation levels. This is where the switch case statement provides a cleaner alternative.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_a_Switch_Case_Statement\"><\/span>What is a Switch Case Statement?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Switch case statements, found in many other programming languages, offer a more structured way to handle scenarios where multiple comparisons are required to make a decision. They allow us to branch execution to different parts of the code based on the value of an expression, providing a cleaner alternative to lengthy <code>if-elif-else<\/code> chains. <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"530\" src=\"https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/09\/Untitled-Diagram.drawio-1-2.png\" alt=\"\" class=\"wp-image-8309\" style=\"width:416px;height:auto\" srcset=\"https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/09\/Untitled-Diagram.drawio-1-2.png 530w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/09\/Untitled-Diagram.drawio-1-2-300x300.png 300w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/09\/Untitled-Diagram.drawio-1-2-150x150.png 150w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><figcaption class=\"wp-element-caption\">Flowchart: Switch Case<\/figcaption><\/figure>\n<\/div><\/div>\n<\/div>\n\n\n\n<p>The flow chart above illustrates the workings of a switch case statement.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The switch case expression is evaluated once. <\/li>\n\n\n\n<li>The value of the evaluated expression is compared with each case. <\/li>\n\n\n\n<li>If a match is found the corresponding statement (or block of code) is executed &#8211; End Switch.<\/li>\n\n\n\n<li>If no match is found, the default statement gets executed &#8211; End Switch.<\/li>\n<\/ul>\n\n\n\n<p>Switch Case&nbsp;is a selection control statement. Also known as a conditional control statement, these statements direct the flow of execution based on whether certain conditions are true or false. It evaluates conditions and executes different blocks of code depending on the outcome.<\/p>\n\n\n\n<p>Although Python lacks traditional switch case statements, it introduces similar functionality with the <code>match<\/code> and <code>case<\/code> statements starting from Python 3.10. Let&#8217;s learn about it in more detail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Pythons_Match_and_Case\"><\/span>Python&#8217;s Match and Case<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Syntax<\/h3>\n\n\n\n<p><strong>1. <code>match<\/code> Statement:<\/strong><br>The <code>match<\/code> statement is used to start pattern matching on a variable. It examines the value of the variable against various patterns defined in the subsequent <code>case<\/code> statements.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"match variable:\n    # Pattern matching cases here\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C586C0\">match<\/span><span style=\"color: #D4D4D4\"> variable:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #6A9955\"># Pattern matching cases here<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>2. <code>case<\/code> Statement:<\/strong><br>Each <code>case<\/code> specifies a pattern to match against the variable\u2019s value. The code block following the <code>case<\/code> is executed if the pattern matches. You can use guards (additional conditions) with <code>case<\/code> statements to refine the matching criteria.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"match variable:\n    case pattern:\n        # Code to execute if pattern matches\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C586C0\">match<\/span><span style=\"color: #D4D4D4\"> variable:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> pattern:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Code to execute if pattern matches<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>3. Using Guards:<\/strong><br>Guards are conditional expressions that can be used in <code>case<\/code> statements to add extra conditions to the match.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"match variable:    \n    case _ if condition:\n        # Code to execute if condition is true\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C586C0\">match<\/span><span style=\"color: #D4D4D4\"> variable:    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> _ <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> condition:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Code to execute if condition is true<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The underscore can be used for two purposes:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Wildcard Pattern<\/strong>: The underscore <code>_<\/code> is used as a wildcard pattern that matches any value. It acts as a catch-all for values that do not match other specific patterns defined in the <code>case<\/code> statements.<\/li>\n<\/ol>\n\n\n\n<p>2. <strong>Guard Conditions<\/strong>: When used with a guard (<code>if condition<\/code>),  the underscore in <code>case _ if condition:<\/code> means that any value is acceptable as long as the <code>condition<\/code> specified in the guard is true. This allows additional conditions to be applied to the match process.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"def evaluate_number(n):\n    match n:\n        case 1:\n            print(&quot;Number is one.&quot;)\n        case 2:\n            print(&quot;Number is two.&quot;)\n        case _ if n < 0:\n            print(&quot;Number is negative.&quot;)\n        case _ if n % 2 == 0:\n            print(&quot;Number is even.&quot;)\n        case _:\n            print(&quot;Number is odd and positive.&quot;)\n\nevaluate_number(4)  # Output: Number is even.\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">evaluate_number<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">n<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">match<\/span><span style=\"color: #D4D4D4\"> n:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Number is one.&quot;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Number is two.&quot;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> _ <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> n &lt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Number is negative.&quot;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> _ <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> n % <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\"> == <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Number is even.&quot;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> _:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Number is odd and positive.&quot;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">evaluate_number(<\/span><span style=\"color: #B5CEA8\">4<\/span><span style=\"color: #D4D4D4\">)  <\/span><span style=\"color: #6A9955\"># Output: Number is even.<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><code>case 1:<\/code><\/strong> Matches if <code>n<\/code> is exactly.<\/li>\n\n\n\n<li><strong><code>case 2:<\/code><\/strong> Matches if <code>n<\/code> is exactly.<\/li>\n\n\n\n<li><strong><code>case _ if n &lt; 0:<\/code><\/strong> Matches any value of <code>n<\/code> if it is less than <code>0<\/code>. Here, <code>_<\/code> indicates that the specific value is not important as long as the condition <code>n &lt; 0<\/code> is true.<\/li>\n\n\n\n<li><strong><code>case _ if n % 2 == 0:<\/code><\/strong> Matches any value of <code>n<\/code> if it is an even number. The underscore <code>_<\/code> is used here to indicate that any value can be matched as long as it satisfies the condition <code>n % 2 == 0<\/code>.<\/li>\n\n\n\n<li><strong><code>case _:<\/code><\/strong> Acts as a default case that catches any value not matched by the previous <code>case<\/code> statements.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Code Implementation<\/h3>\n\n\n\n<p>The <code>match<\/code> statement allows for pattern matching, where you can check a variable against multiple patterns. Each <code>case<\/code> within the <code>match<\/code> block specifies a pattern to compare with the variable&#8217;s value, enabling clear and concise branching logic. <\/p>\n\n\n\n<p>This concept can be more clearly illustrated with an example that converts a basic <code>if<\/code>, <code>elif<\/code>, and <code>else<\/code> structure into a <code>match<\/code> and <code>case<\/code> structure.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"def determine_age_group(age):\n    if age < 0:\n        return &quot;Invalid age&quot;\n    elif age <= 12:\n        return &quot;Child&quot;\n    elif age <= 19:\n        return &quot;Teenager&quot;\n    elif age <= 64:\n        return &quot;Adult&quot;\n    else:\n        return &quot;Senior&quot;\n\nprint(determine_age_group(25))  # Output: Adult\n\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">determine_age_group<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">age<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> age &lt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Invalid age&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">elif<\/span><span style=\"color: #D4D4D4\"> age &lt;= <\/span><span style=\"color: #B5CEA8\">12<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Child&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">elif<\/span><span style=\"color: #D4D4D4\"> age &lt;= <\/span><span style=\"color: #B5CEA8\">19<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Teenager&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">elif<\/span><span style=\"color: #D4D4D4\"> age &lt;= <\/span><span style=\"color: #B5CEA8\">64<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Adult&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Senior&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(determine_age_group(<\/span><span style=\"color: #B5CEA8\">25<\/span><span style=\"color: #D4D4D4\">))  <\/span><span style=\"color: #6A9955\"># Output: Adult<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Explanation: <\/strong>The <code>determine_age_group()<\/code> function categorizes a person&#8217;s age into life stages. It checks if the age is invalid (less than 0), or falls into specific ranges: &#8220;Child&#8221; (0-12), &#8220;Teenager&#8221; (13-19), &#8220;Adult&#8221; (20-64), or &#8220;Senior&#8221; (65 and older). For the input 25, it matches the &#8220;Adult&#8221; category and returns &#8220;Adult&#8221;, which is then printed.<\/p>\n\n\n\n<p>In the <code>match<\/code>&#8211;<code>case<\/code> version, we use pattern matching with guard conditions (using <code>if<\/code> within the <code>case<\/code> statements) to handle the different age ranges and special cases. This provides a similar logical structure to the <code>if<\/code>, <code>elif<\/code>, and <code>else<\/code> approach but leverages the new pattern matching capabilities introduced in Python 3.10.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"def determine_age_group(age):\n    match age:\n        case _ if age < 0:\n            return &quot;Invalid age&quot;\n        case age if age <= 12:\n            return &quot;Child&quot;\n        case age if age <= 19:\n            return &quot;Teenager&quot;\n        case age if age <= 64:\n            return &quot;Adult&quot;\n        case _:\n            return &quot;Senior&quot;\n\nprint(determine_age_group(25))  # Output: Adult\n\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">determine_age_group<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">age<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">match<\/span><span style=\"color: #D4D4D4\"> age:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> _ <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> age &lt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Invalid age&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> age <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> age &lt;= <\/span><span style=\"color: #B5CEA8\">12<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Child&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> age <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> age &lt;= <\/span><span style=\"color: #B5CEA8\">19<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Teenager&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> age <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> age &lt;= <\/span><span style=\"color: #B5CEA8\">64<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Adult&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> _:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;Senior&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">print<\/span><span style=\"color: #D4D4D4\">(determine_age_group(<\/span><span style=\"color: #B5CEA8\">25<\/span><span style=\"color: #D4D4D4\">))  <\/span><span style=\"color: #6A9955\"># Output: Adult<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Explanation: <\/strong>The <code>determine_age_group()<\/code> function utilizes Python&#8217;s <code>match<\/code> and <code>case<\/code> statements to categorize a person&#8217;s age. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It begins with the <code>match age:<\/code> statement, which initiates the pattern matching process for <code>age<\/code>. <\/li>\n\n\n\n<li>The function then evaluates a series of <code>case<\/code> statements. If the case is true, the subsequent code block, a return statement in this example, is executed.<\/li>\n\n\n\n<li> The cases match ages falling within specific ranges: <code>age&lt;0<\/code> for &#8220;Invalid age&#8221;, <code>age&lt;=12<\/code> for &#8220;Child&#8221;, <code>age&lt;=19<\/code> for &#8220;Teenager&#8221;, and <code>age&lt;=64<\/code> for &#8220;Adult&#8221;. The final case, <code>case _:<\/code>, acts as a default catch-all for ages above 64, returning &#8220;Senior&#8221;. <\/li>\n\n\n\n<li>When <code>determine_age_group(25)<\/code> is called, the function matches the <code>age&lt;=64<\/code> case, thus returning &#8220;Adult&#8221;, which is then printed.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Python uses <code>match<\/code> and <code>case<\/code> statements to imitate the functionality of a Switch Case statement. It offers a more organized alternative to <code>if<\/code>, <code>elif<\/code>, and <code>else<\/code> for handling multiple conditions. This approach simplifies complex decision-making and improves code readability, making it a valuable tool for Python developers.<\/p>\n\n\n\n<p>Python is also crucial in the context of blockchain development. Its versatility and powerful libraries make it a good choice for building and interacting with blockchain systems. To understand why Python is so effective for blockchain projects, check out our article,<a href=\"https:\/\/metaschool.so\/articles\/reasons-why-develop-blockchain-python\/\">&nbsp;7 Reasons Why You Should Develop a Blockchain Using Python<\/a>&nbsp;which explores the numerous advantages of using Python for blockchain development.<\/p>\n\n\n\n<p><strong>Related Reading:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/metaschool.so\/articles\/python-exponents\">Python Exponent: Complete Guide To Exponents in Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/metaschool.so\/articles\/python-block-comment\">How to Comment A Code Block in Python \u2014 Explained<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/metaschool.so\/articles\/python-check-if-file-exists\">How to check if a file exists in Python?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/metaschool.so\/articles\/python-string-length\">How to Use Python String Length?<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1735017267878\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What is the purpose of Python&#8217;s <code>match<\/code> and <code>case<\/code> statements?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Python&#8217;s <code>match<\/code> and <code>case<\/code> statements provide a way to perform pattern matching, allowing developers to execute code blocks based on the structure and content of data. This feature offers a more readable and organized approach to handling multiple conditions compared to traditional <code>if<\/code>, <code>elif<\/code>, and <code>else<\/code> statements. <a href=\"https:\/\/www.geeksforgeeks.org\/python-match-case-statement\/?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1735017309472\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>How do <code>match<\/code> and <code>case<\/code> differ from <code>if-elif-else<\/code> statements?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>While <code>if-elif-else<\/code> statements evaluate boolean expressions to control program flow, <code>match<\/code> and <code>case<\/code> statements enable structural pattern matching, allowing for more complex and expressive condition handling. This distinction makes <code>match-case<\/code> particularly useful for scenarios involving intricate data structures. <a href=\"https:\/\/stackoverflow.com\/questions\/67961895\/how-do-if-statements-differ-from-match-case-statments-in-python?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1735017518431\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Can <code>match-case<\/code> statements replace all <code>if-elif-else<\/code> scenarios?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>No, <code>match-case<\/code> statements are best suited for situations requiring pattern matching and may not be appropriate for all conditional logic. Simple conditions can still be effectively handled using <code>if-elif-else<\/code> statements. <a href=\"https:\/\/www.reddit.com\/r\/learnpython\/comments\/1by6vht\/should_i_use_match_case_instead_of_if_else\/?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1735017529742\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What are some practical applications of <code>match-case<\/code> statements in Python?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p><code>Match-case<\/code> statements are particularly useful for parsing complex data structures, implementing state machines, and handling multiple input scenarios where pattern matching enhances code clarity and maintainability. <a href=\"https:\/\/medium.com\/%40sjalexandre\/python-tutorial-control-flow-match-case-9c9525623f2?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":19,"featured_media":10938,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[292],"tags":[],"class_list":["post-8291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-answers"],"_links":{"self":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/8291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/comments?post=8291"}],"version-history":[{"count":24,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/8291\/revisions"}],"predecessor-version":[{"id":11896,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/8291\/revisions\/11896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media\/10938"}],"wp:attachment":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media?parent=8291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/categories?post=8291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/tags?post=8291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}