{"id":12154,"date":"2020-12-02T08:38:46","date_gmt":"2020-12-02T16:38:46","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12154"},"modified":"2023-12-01T04:05:10","modified_gmt":"2023-12-01T12:05:10","slug":"python-try-except","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-try-except\/","title":{"rendered":"Python Try Except: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>The Python try&#8230;except statement catches an exception. It is used to test code for an error which is written in the &#8220;try&#8221; statement. If an error is encountered, the contents of the &#8220;except&#8221; block are run.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How to Use Try and Except in Python<\/h2>\n\n\n\n<p>You may want to test a specific block of code to ensure it functions correctly before allowing the rest of the program to run. For example, say you have written a large amount of new code for a program. You would want to make sure it works before letting the rest of the program run.<\/p>\n\n\n\n<p>try&#8230;except blocks let you test your code and handle an exception if one is raised. You can add finally and else statements to run additional code depending on the outcome of the try&#8230;except block.<\/p>\n\n\n\n<p>In this tutorial, we are going to talk about how to use try and except in Python. We&#8217;ll refer to an example so you can quickly get started using try and except.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Errors and Exceptions Refresher<\/h2>\n\n\n\n<p>In Python, there are two kinds of errors you may encounter: syntax errors and exceptions.<\/p>\n\n\n\n<p><a href=\"https:\/\/careerkarma.com\/blog\/python-syntaxerror-invalid-syntax\/\">Python syntax errors<\/a> are a type of error that returns when you use the wrong syntax. For example, if you write a <em>while True<\/em> loop without a colon at the end, the program will report an error.<\/p>\n\n\n\n<p>When syntax errors occur, they return the file name, line number, and an indicator of where an error may be present.<\/p>\n\n\n\n<p>Exceptions are a type of error where code may have the right syntax but still contains a problem. There are many types of exception, but some of the most common you will encounter include: ArithmeticError, ImportError, ZeroDivisionError, <a href=\"https:\/\/careerkarma.com\/blog\/python-nameerror-name-is-not-defined\/\">NameError<\/a>, and TypeError.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python try&#8230;except Statement<\/h2>\n\n\n\n<p>The Python try&#8230;except statement runs the code under the &#8220;try&#8221; statement. If this code does not execute successfully, the program will stop at the line that caused the error and the &#8220;except&#8221; code will run.<\/p>\n\n\n\n<p>The try block allows you to test a block of code for errors. The except block enables you to handle the error with a user-defined response. <\/p>\n\n\n\n<p>Here is the syntax for the try&#8230;except block:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tyourcode...\nexcept:\n\tyourcode...<\/pre><\/div>\n\n\n\n<p>You can enclose any valid Python code within a try or except statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">try&#8230;except Python Example<\/h2>\n\n\n\n<p>Here\u2019s an example of the syntax for try&#8230;except blocks:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tprint(ourVariable)\nexcept:\n\tprint('Error returned')<\/pre><\/div>\n\n\n\n<p>In the above example, we have not declared the <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> <em>ourVariable<\/em>, yet we try to use it in our try block.<\/p>\n\n\n\n<p>If we did not have try&#8230;except blocks in our code, the program would return an error message. While seeing an error message is fine during debugging, a regular user may get confused if they see an error message. <\/p>\n\n\n\n<p>Because we have try&#8230;except blocks, our code knows what to do when an error is encountered.<\/p>\n\n\n\n<p>Here is the result of our code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Error returned<\/pre><\/div>\n\n\n\n<p>try&#8230;except blocks let you handle exceptions gracefully. You may also want to implement a feature like saving an exception to a log file using a package like <a href=\"https:\/\/careerkarma.com\/blog\/python-logging\/\">Python&#8217;s logging module<\/a>. This would let you keep track of exceptions that have been raised.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">try&#8230;except Python: Multiple Except Statements<\/h2>\n\n\n\n<p>You can repeat <em>except<\/em> statements for different types of errors to test for multiple exceptions. This is useful if you suspect that one of many exceptions may be raised but you are not sure which one you will encounter.<\/p>\n\n\n\n<p>Here is an example of try&#8230;except blocks that look for a NameError:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tprint(ourVariable)\nexcept NameError:\n\tprint('ourVariable is not defined')\nexcept:\n\tprint('Error returned')<\/pre><\/div>\n\n\n\n<p>In this case, our code returns <em>ourVariable<\/em><em> is not defined<\/em> because our code returns a NameError. We could add more errors, such as a ZeroDivisionError or an OSError, depending on the code we are testing.<\/p>\n\n\n\n<p>For instance, you may check for an IOError and a FileNotFoundError if you want to open a file. Checking for multiple exceptions would ensure your program could continue running even if there was an error opening the file you reference.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">try&#8230;except Python: Finally<\/h2>\n\n\n\n<p>But what if we want a message to print both if an error is returned and if no error is found? That\u2019s where the <em>finally<\/em> block comes in. If you define a finally clause, its contents will be executed irrespective of whether the try&#8230;except block raises an error.<\/p>\n\n\n\n<p>Finally blocks are a useful indicator that you code has executed. Because they do not differentiate between whether a code has successfully executed, they are not as commonly used.<\/p>\n\n\n\n<p>Here\u2019s an example:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tprint(ourVariable)\nexcept:\n\tprint('ourVariable is not defined')\nfinally:\n\tprint('Code has been run.')<\/pre><\/div>\n\n\n\n<p>Our program returns the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ourVariable is not defined\nCode has been run.<\/pre><\/div>\n\n\n\n<p>The code within the <em>except<\/em> block executes because there is an exception found in our code (ourVariable is not defined). The code within the <em>finally<\/em> clause executes as well, because our code has finished running.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">try&#8230;except Python: Else<\/h2>\n\n\n\n<p>By using an else clause, you can define code that will be run in the case that no exceptions are raised. This could be used to inform a user that a program has successfully executed, for instance.<\/p>\n\n\n\n<p>Imagine if you were creating a sign up system for a game. You may include a try&#8230;except&#8230;else block to check if a username or email address that a user selects is valid. If it is not, the except clause would run. If the username or email address is valid, the else block could run.<\/p>\n\n\n\n<p>Here\u2019s an example:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tprint('Test')\nexcept:\n\tprint('There is a problem.')\nelse:\n\tprint('There are no problems.')<\/pre><\/div>\n\n\n\n<p>Our code returns the following: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>There are no problems.<\/pre><\/div>\n\n\n\n<p>Our Python program encounters no exceptions. As a result, the code within the <em>else<\/em> statement executes. The <em>else<\/em> statement prints out the message stating there are no problems with our code.<\/p>\n\n\n\n<p><strong>View the Repl.it from this tutorial:<\/strong><\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/Python-Try-Except?lite=true\" width=\"100%\" height=\"400px\" frameborder=\"0\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>try&#8230;except blocks make it easy to debug your Python code. A program tries to run the code in a &#8220;try&#8221; block. If this fails, the &#8220;except&#8221; block runs. The code in a &#8220;finally&#8221; statement runs irrespective of whether an &#8220;except&#8221; block is executed.<\/p>\n\n\n\n<p>In this tutorial, we have broken down how to use try&#8230;except blocks. We have discussed how to use <em>else<\/em> and <em>except<\/em> to customize your exception handling.<\/p>\n\n\n\n<p>These blocks can be useful when you\u2019re testing existing code or writing new code. It ensures that your program runs correctly and contains no errors.<\/p>\n\n\n\n<p>For more Python learning resources, check out our comprehensive <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"The Python try...except statement catches an exception. It is used to test code for an error which is written in the \"try\" statement. If an error is encountered, the contents of the \"except\" block are run. How to Use Try and Except in Python You may want to test a specific block of code to&hellip;","protected":false},"author":240,"featured_media":12054,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[12687],"class_list":{"0":"post-12154","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python","8":"tag-tutorial"},"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 Try Except: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The Python try except block tests for exceptions and handles errors. Learn about how to use try, except, and else, in this article.\" \/>\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-try-except\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Try Except: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"The Python try except block tests for exceptions and handles errors. Learn about how to use try, except, and else, in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-try-except\/\" \/>\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-12-02T16:38:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"562\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Try Except: A Step-By-Step Guide\",\"datePublished\":\"2020-12-02T16:38:46+00:00\",\"dateModified\":\"2023-12-01T12:05:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/\"},\"wordCount\":1041,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg\",\"keywords\":[\"tutorial\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-try-except\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/\",\"name\":\"Python Try Except: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg\",\"datePublished\":\"2020-12-02T16:38:46+00:00\",\"dateModified\":\"2023-12-01T12:05:10+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Python try except block tests for exceptions and handles errors. Learn about how to use try, except, and else, in this article.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-try-except\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg\",\"width\":1000,\"height\":562},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-try-except\/#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 Try Except: A Step-By-Step 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 Try Except: A Step-By-Step Guide | Career Karma","description":"The Python try except block tests for exceptions and handles errors. Learn about how to use try, except, and else, in this article.","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-try-except\/","og_locale":"en_US","og_type":"article","og_title":"Python Try Except: A Step-By-Step Guide","og_description":"The Python try except block tests for exceptions and handles errors. Learn about how to use try, except, and else, in this article.","og_url":"https:\/\/careerkarma.com\/blog\/python-try-except\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-02T16:38:46+00:00","article_modified_time":"2023-12-01T12:05:10+00:00","og_image":[{"width":1000,"height":562,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Try Except: A Step-By-Step Guide","datePublished":"2020-12-02T16:38:46+00:00","dateModified":"2023-12-01T12:05:10+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/"},"wordCount":1041,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg","keywords":["tutorial"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-try-except\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/","url":"https:\/\/careerkarma.com\/blog\/python-try-except\/","name":"Python Try Except: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg","datePublished":"2020-12-02T16:38:46+00:00","dateModified":"2023-12-01T12:05:10+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Python try except block tests for exceptions and handles errors. Learn about how to use try, except, and else, in this article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-try-except\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg","width":1000,"height":562},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-try-except\/#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 Try Except: A Step-By-Step 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\/12154","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=12154"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12154\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12054"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}