{"id":22123,"date":"2020-09-04T09:55:02","date_gmt":"2020-09-04T16:55:02","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=22123"},"modified":"2023-12-01T03:59:23","modified_gmt":"2023-12-01T11:59:23","slug":"python-switch","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-switch\/","title":{"rendered":"Python Switch Statement: A How-to Guide"},"content":{"rendered":"\n<p><a href=\"https:\/\/careerkarma.com\/blog\/java-switch-statement\/\">Unlike Java or C#<\/a>, Python does not have a built-in switch statement. This means you cannot evaluate a switch expression without having to write your own code that mimics a \u201cswitch&#8230;case\u201d statement.<br><\/p>\n\n\n\n<p>In this guide, we discuss how to write a \u201cswitch&#8230;case\u201d in Python, and walk through two examples of a faux-switch statement so you can learn how to write one in your code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Switch Statements: A Refresher<\/h2>\n\n\n\n<p>A switch statement lets you select one of a set of code blocks to run. They are a way of evaluating multiple expressions in a program.<br><\/p>\n\n\n\n<p>A switch statement works by evaluating a switch statement and comparing the result of that statement with values in \u201ccase\u201d statements. If a match is found, the respective block of code is run. Otherwise, nothing will happen.<br><\/p>\n\n\n\n<p>Optionally, a \u201cdefault\u201d keyword is used to run a block of code if no statement is found that matches a particular expression.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Switch Statement: Returning Individual Values<\/h2>\n\n\n\n<p>Let\u2019s write a program that converts a numerical value to a day of the week.<br><\/p>\n\n\n\n<p>To start, ask a user to <a href=\"https:\/\/careerkarma.com\/blog\/python-input\/\">insert a number<\/a> they want to convert into a written day:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>convert_to_day = int(input(&quot;Insert a day of the week: &quot;))<\/pre><\/div>\n\n\n\n<p>We convert the value the user inserts into our program to an integer. We\u2019ll discuss why this is necessary later in the tutorial.<br><\/p>\n\n\n\n<p>Next, we <a href=\"https:\/\/careerkarma.com\/blog\/python-add-to-dictionary\/\">define a dictionary<\/a>. This dictionary will contain all the days of a week. Each key will store a day as a number and each value will store a day written out (i.e. Tuesday):<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>days = {\n\t   1: &quot;Monday&quot;,\n\t   2: &quot;Tuesday&quot;,\n\t   3: &quot;Wednesday&quot;,\n\t   4: &quot;Thursday&quot;,\n\t   5: &quot;Friday&quot;,\n\t   6: &quot;Saturday&quot;,\n\t   7: &quot;Sunday&quot;\n}<\/pre><\/div>\n\n\n\n<p>There are seven keys and values in our dictionary. The key \u201c1\u201d represents \u201cMonday\u201d and so on until the final day of the week.<br><\/p>\n\n\n\n<p>Next, we use the <a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\">dictionary get() method<\/a> to access the item in this dictionary that corresponds with the value a user has inserted:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>day_as_written = days.get(convert_to_day, &quot;There is no day with this numerical value.&quot;)\nprint(day_as_written)<\/pre><\/div>\n\n\n\n<p>We\u2019ve converted the value a user inserted into our program to an integer so we can use it in our <code>get()<\/code> statement. If there is no key equal to the value that \u201cconvert_to_day\u201d stores, our code will return \u201cThere is no day with this numerical value.\u201d<br><\/p>\n\n\n\n<p>If a user inserts the value \u201c1\u201d, our code will evaluate:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>days[1]<\/pre><\/div>\n\n\n\n<p>This will retrieve the value associated with the key \u201c1\u201d in our list.<br><\/p>\n\n\n\n<p>Let\u2019s run our code and see what happens:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Insert a day of the week: 1\nMonday<\/pre><\/div>\n\n\n\n<p>Our code successfully converts the number a user inserts to a string. Let\u2019s run our code on a day that does not exist in our dictionary:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Insert a day of the week: 8\nThere is no day with this numerical value.<\/pre><\/div>\n\n\n\n<p>Our code works even if a user inserts an invalid value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Switch Statement: Calling Functions<\/h2>\n\n\n\n<p>We can use this syntax to <a href=\"https:\/\/careerkarma.com\/blog\/python-functions\/\">call functions in our code<\/a>. We\u2019re going to build an application that displays information about a list of purchases at a sandwich store.<br><\/p>\n\n\n\n<p>First, let\u2019s define a list of purchases:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>purchases = [2.50, 2.50, 2.75, 3.90, 5.60, 2.40]<\/pre><\/div>\n\n\n\n<p>Next, define three functions. These functions will calculate:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The number of purchases in our list<\/li><li>The average purchase value<\/li><li>The largest purchase<\/li><\/ul>\n\n\n\n<p>Let\u2019s define these functions:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def number_of_purchases():\n\t   total = len(purchases)\n\t   print(total)\n\ndef average_value():\n\t   average = sum(purchases) \/ len(purchases)\n\t   print(average)\n\ndef largest_purchase():\n\t   largest = max(purchases)\n\t   print(largest)<\/pre><\/div>\n\n\n\n<p>Now that we have defined these functions, start to write our faux-switch statement. Like we\u2019ve done in our first example, we start by asking a user to insert a value. The value a user inserts should correspond to one of our functions.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(&quot;[1] Display the number of purchases made today&quot;)\nprint(&quot;[2] Display the average value of all the purchases made today&quot;)\nprint(&quot;[3] Display the largest purchase made today&quot;)\nto_run = int(input(&quot;What would you like to do? &quot;))<\/pre><\/div>\n\n\n\n<p>Our code prints out three messages. Each one informs a user of an option they can take. Our code then asks a user to insert a value. We convert this value to a number so we can use it later in our program.<br><\/p>\n\n\n\n<p>Next, define a dictionary that maps our functions to numbers:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>options = {\n\t\t1: number_of_purchases,\n\t\t2: average_value,\n\t\t3: largest_purchase\n}<\/pre><\/div>\n\n\n\n<p>The value \u201c1\u201d is mapped to the function called \u201cnumber_of_purchases\u201d, the value \u201c2\u201d is mapped to the function \u201caverage_value\u201d, and the value \u201c3\u201d is mapped to the \u201clargest_purchase\u201d function.<br><\/p>\n\n\n\n<p>Next, use the <code>get()<\/code> method to select which function our program should run:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>function_to_execute = options.get(to_run)\nfunction_to_execute()<\/pre><\/div>\n\n\n\n<p>This code retrieves the function from our dictionary that we want to execute. We haven&#8217;t specified a second value in our <code>get()<\/code> method because we need to call a function for our code to work. This means if a user inserts an invalid value, our code returns an error. There are ways to handle this behavior but doing so is outside the scope of this tutorial.<br><\/p>\n\n\n\n<p>Let\u2019s run our code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[1] Display the number of purchases made today\n[2] Display the average value of all the purchases made today\n[3] Display the largest purchase made today\nWhat would you like to do? 3\n5.6<\/pre><\/div>\n\n\n\n<p>We have selected option 3 from our list. Our code successfully prints out the largest purchase made on a particular day. Let\u2019s try to select option 2:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[1] Display the number of purchases made today\n[2] Display the average value of all the purchases made today\n[3] Display the largest purchase made today\nWhat would you like to do? 2\n3.275<\/pre><\/div>\n\n\n\n<p>Our code returns the average value of the purchases in our list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>While Python does not have a built-in switch statement, you can create one using a dictionary and the <code>get()<\/code> method.<br><\/p>\n\n\n\n<p>Switch statements are useful if you want to evaluate an expression against multiple potential outcomes.<br><\/p>\n\n\n\n<p>You can write a faux-switch statement that retrieves values from a dictionary depending on the key you specify. You can also write a faux-switch statement that retrieves a function from a dictionary based on a particular key that you reference.<br><\/p>\n\n\n\n<p>Now you\u2019re ready to build your own switch statements in the <a href=\"https:\/\/careerkarma.com\/blog\/what-python-is-used-for\/\">Python programming language<\/a> like an expert coder!<\/p>\n","protected":false},"excerpt":{"rendered":"Unlike Java or C#, Python does not have a built-in switch statement. This means you cannot evaluate a switch expression without having to write your own code that mimics a \u201cswitch...case\u201d statement. In this guide, we discuss how to write a \u201cswitch...case\u201d in Python, and walk through two examples of a faux-switch statement so you&hellip;","protected":false},"author":240,"featured_media":15192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-22123","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Switch Statement: A How-to Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn how to write a switch statement in Python using a dictionary with a store of values or functions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-switch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Switch Statement: A How-to Guide\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn how to write a switch statement in Python using a dictionary with a store of values or functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-switch\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-04T16:55:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:59:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Switch Statement: A How-to Guide\",\"datePublished\":\"2020-09-04T16:55:02+00:00\",\"dateModified\":\"2023-12-01T11:59:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/\"},\"wordCount\":834,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-switch\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-switch\/\",\"name\":\"Python Switch Statement: A How-to Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg\",\"datePublished\":\"2020-09-04T16:55:02+00:00\",\"dateModified\":\"2023-12-01T11:59:23+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn how to write a switch statement in Python using a dictionary with a store of values or functions.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-switch\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-switch\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Switch Statement: A How-to Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Switch Statement: A How-to Guide | Career Karma","description":"On Career Karma, learn how to write a switch statement in Python using a dictionary with a store of values or functions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/python-switch\/","og_locale":"en_US","og_type":"article","og_title":"Python Switch Statement: A How-to Guide","og_description":"On Career Karma, learn how to write a switch statement in Python using a dictionary with a store of values or functions.","og_url":"https:\/\/careerkarma.com\/blog\/python-switch\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-09-04T16:55:02+00:00","article_modified_time":"2023-12-01T11:59:23+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-switch\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Switch Statement: A How-to Guide","datePublished":"2020-09-04T16:55:02+00:00","dateModified":"2023-12-01T11:59:23+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-switch\/"},"wordCount":834,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-switch\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-switch\/","url":"https:\/\/careerkarma.com\/blog\/python-switch\/","name":"Python Switch Statement: A How-to Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg","datePublished":"2020-09-04T16:55:02+00:00","dateModified":"2023-12-01T11:59:23+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn how to write a switch statement in Python using a dictionary with a store of values or functions.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-switch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/avel-chuklanov-DUmFLtMeAbQ-unsplash.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-switch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Switch Statement: A How-to Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/22123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=22123"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/22123\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15192"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=22123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=22123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=22123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}