{"id":23440,"date":"2020-10-01T00:56:20","date_gmt":"2020-10-01T07:56:20","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=23440"},"modified":"2023-12-01T04:01:20","modified_gmt":"2023-12-01T12:01:20","slug":"python-exceptions","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-exceptions\/","title":{"rendered":"Python Exceptions: A Guide"},"content":{"rendered":"\n<p>Exceptions can be raised by the Python interpreter and manually. Built-in exceptions help catch common errors in a program.<\/p>\n\n\n\n<p>In this guide, we\u2019re going to discuss what an exception is and how they are used. We\u2019ll walk through an example of how to raise an exception so you can work with them in your code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an Exception?<\/h2>\n\n\n\n<p>An exception, also called a logical error, is an error that occurs during program runtime.<br><\/p>\n\n\n\n<p>There are two types of errors in Python: <a href=\"https:\/\/careerkarma.com\/blog\/python-syntaxerror-continue-not-properly-in-loop\/\">syntax errors<\/a> and runtime errors. Syntax errors are raised before a program runs. If your program encounters a syntax error, your program will not be able to run. This is because Python cannot interpret code that contains syntax errors.<br><\/p>\n\n\n\n<p>Runtime errors, also called exceptions, are encountered while Python runs a program. An exception may be raised on line 30 of a program. If an exception is raised on line 30, 30 lines of code will run, then the program will stop.<br><\/p>\n\n\n\n<p>Here is an example of an exception:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Traceback (most recent call last):\n  File &quot;main.py&quot;, line 6, in &lt;module&gt;\n\ts_names.append(n)\nAttributeError: 'str' object has no attribute 'append'<\/pre><\/div>\n\n\n\n<p>This exception tells us Python cannot run the rest of our code. If you encounter an exception, you should carefully read the message. The error message will tell you most, if not all, of what you need to know to solve an error.<br><\/p>\n\n\n\n<p>Let\u2019s break down the last sentence in our error message:<br><\/p>\n\n\n\n<p><a href=\"https:\/\/careerkarma.com\/blog\/python-attributeerror-str-object-has-no-attribute-append\/\">AttributeError: \u2018str\u2019 object has no attribute \u2018append\u2019<\/a><br><\/p>\n\n\n\n<p>In this case, we know our error is an AttributeError. This means we\u2019re trying to reference an attribute that does not exist. Our error message tells us we are trying to use append() on a string object, which is not allowed.<br><\/p>\n\n\n\n<p>Because string objects do not support the <code>append()<\/code> method, a good next step is to look for the equivalent of <code>append()<\/code> for strings. This is concatenation. Now we have a potential solution to our programming issue that we can apply.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where May I Encounter an Exception?<\/h2>\n\n\n\n<p>To help programmers catch errors in their code, Python has a range of built-in exceptions. These exceptions can help you identify the cause of an issue in your code so you can fix them. Below are a few of the most common exceptions you\u2019re likely to encounter:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>TypeError: Occurs when you apply a function to an object whose type does not support that function. (e.g. <a href=\"https:\/\/careerkarma.com\/blog\/python-typeerror-can-only-join-an-iterable\/\">TypeError: can only join an iterable<\/a>)<\/li><li>SyntaxError: Raised before a program executes to tell you that there is an issue in your syntax (e.g. SyntaxError: invalid syntax)<\/li><li>KeyError: Occurs if you reference a key in a dictionary that does not exist. (e.g. <a href=\"https:\/\/careerkarma.com\/blog\/python-keyerror\/\">KeyError: \u201cusb_ports<\/a>\u201d)<\/li><li>ImportError: Occurs if you try to import a package that does not exist, or a function from a package that does not exist.<\/li><\/ul>\n\n\n\n<p>We\u2019ve only listed a few of the many exceptions that you may encounter in the Python language.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Raise an Exception<\/h2>\n\n\n\n<p>You can define your own custom exceptions in your code. This can be helpful if the built-in exceptions provided by Python do not suit the needs for your program.<br><\/p>\n\n\n\n<p>We\u2019re going to write a program that validates a password for a game. To start, let\u2019s ask the user to insert a password:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>password = input(&quot;Enter a password: &quot;)<\/pre><\/div>\n\n\n\n<p>For the user\u2019s password to be valid, it must be more than 12 characters long. If the user\u2019s password is 12 characters or fewer, we want to raise an exception.<br><\/p>\n\n\n\n<p>To do this, we\u2019re going to use an <a href=\"https:\/\/careerkarma.com\/blog\/python-if-else\/\">if statement<\/a>. The following if statement will check if the password a user has chosen is fewer than 12 characters:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>if len(password) &gt; 12:\n\tprint(&quot;Your password is valid.&quot;)\nelse:\n\traise Exception(&quot;Your password is not the correct length.&quot;)<\/pre><\/div>\n\n\n\n<p>We use the <a href=\"https:\/\/careerkarma.com\/blog\/python-len\/\">len() method<\/a> to calculate the length of a user\u2019s password. If a user inserts an invalid password, our program will raise an exception with a message stating \u201cYour password is not the correct length.\u201d<br><\/p>\n\n\n\n<p>Let\u2019s try out our code to see if it works:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter a password: Bacon120\nTraceback (most recent call last):\n  File &quot;main.py&quot;, line 6, in &lt;module&gt;\n\traise Exception(&quot;Your password is not the correct length.&quot;)\nException: Your password is not the correct length.<\/pre><\/div>\n\n\n\n<p>The password we entered was under 12 characters. Our code stops because we entered an invalid password. Let\u2019s try to run our program with a valid password: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter a password: Bacon120Bacon120\nYour password is valid.<\/pre><\/div>\n\n\n\n<p>Our program executes successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Handle an Exception<\/h2>\n\n\n\n<p>By default, exceptions will stop the execution of a program. While this is useful because it forces you to find the solution to an error, there are some cases where you may not want your program to stop executing if an exception is raised.<br><\/p>\n\n\n\n<p>For instance, if you are checking if data points in a list are valid, you may not want an exception to be raised every time an invalid data point is discovered.<br><\/p>\n\n\n\n<p>To handle an exception, you can use a \u201ctry&#8230;except\u201d block. Let\u2019s write a program that finds an item in a dictionary. This dictionary contains a list of names of students in a class and their corresponding grades on their most recent test.<br><\/p>\n\n\n\n<p>To start, let\u2019s define a dictionary with student and grade information:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>data = {\n\t&quot;Lucy&quot;: 73,\n\t&quot;Carlton&quot;: 59,\n\t&quot;Adam&quot;: 73\n}<\/pre><\/div>\n\n\n\n<p>Next, let\u2019s ask a user to insert a name whose grade they want to retrieve. We\u2019re going to do this within a \u201ctry\u201d block so that we can handle an exception later in our code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tstudent = input(&quot;Enter the name of the student whose grade you want to retrieve: &quot;)\n\tprint(data[student])<\/pre><\/div>\n\n\n\n<p>This code will print out the grade of the student whose name matches the one that a user has inserted into the program. However, if a user inserts a name that is invalid, a KeyError will be encountered.<br><\/p>\n\n\n\n<p>We\u2019re going to handle this by adding an except block to our code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>try:\n\tstudent = input(&quot;Enter the name of the student whose grade you want to retrieve: &quot;)\n\tprint(data[student])\nexcept:\n\tprint(&quot;This student is not present in the list of grades.&quot;)<\/pre><\/div>\n\n\n\n<p>If a student cannot be found, the except clause is executed. Let\u2019s run our program:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter the name of the student whose grade you want to retrieve: Lucy\n73<\/pre><\/div>\n\n\n\n<p>When we enter a valid student name, our program works. Let\u2019s try our program if we insert an invalid student name:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter the name of the student whose grade you want to retrieve: Kaitlin\nThis student is not present in the list of grades.<\/pre><\/div>\n\n\n\n<p>An exception is raised but our program does not stop. Instead, the contents of the \u201cexcept\u201d block are executed.<br><\/p>\n\n\n\n<p>To learn more about the try&#8230;except block, <a href=\"https:\/\/careerkarma.com\/blog\/python-try-except\/\">read our guide on Python try&#8230;except<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Exceptions inform you there is a logical error in your code. When an exception is raised, you should see the type of the exception, where the exception was raised, as well as an error message. You can use this information to find the cause of the exception.<br><\/p>\n\n\n\n<p>You can raise your own exceptions using the raise statement. You can handle exceptions using the try&#8230;except block of code.<br><\/p>\n\n\n\n<p>Now you have the tools you need to solve a Python exception like a pro!<\/p>\n","protected":false},"excerpt":{"rendered":"Exceptions can be raised by the Python interpreter and manually. Built-in exceptions help catch common errors in a program. In this guide, we\u2019re going to discuss what an exception is and how they are used. We\u2019ll walk through an example of how to raise an exception so you can work with them in your code.&hellip;","protected":false},"author":240,"featured_media":22628,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-23440","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 Exceptions: A Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Exceptions are logical errors in a Python program. On Career Karma, learn more about what exceptions are and how to raise and handle exceptions.\" \/>\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-exceptions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Exceptions: A Guide\" \/>\n<meta property=\"og:description\" content=\"Exceptions are logical errors in a Python program. On Career Karma, learn more about what exceptions are and how to raise and handle exceptions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-exceptions\/\" \/>\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-10-01T07:56:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:01:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\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-exceptions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Exceptions: A Guide\",\"datePublished\":\"2020-10-01T07:56:20+00:00\",\"dateModified\":\"2023-12-01T12:01:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/\"},\"wordCount\":1053,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/\",\"name\":\"Python Exceptions: A Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg\",\"datePublished\":\"2020-10-01T07:56:20+00:00\",\"dateModified\":\"2023-12-01T12:01:20+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Exceptions are logical errors in a Python program. On Career Karma, learn more about what exceptions are and how to raise and handle exceptions.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-exceptions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-exceptions\/#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 Exceptions: A 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 Exceptions: A Guide | Career Karma","description":"Exceptions are logical errors in a Python program. On Career Karma, learn more about what exceptions are and how to raise and handle exceptions.","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-exceptions\/","og_locale":"en_US","og_type":"article","og_title":"Python Exceptions: A Guide","og_description":"Exceptions are logical errors in a Python program. On Career Karma, learn more about what exceptions are and how to raise and handle exceptions.","og_url":"https:\/\/careerkarma.com\/blog\/python-exceptions\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-01T07:56:20+00:00","article_modified_time":"2023-12-01T12:01:20+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Exceptions: A Guide","datePublished":"2020-10-01T07:56:20+00:00","dateModified":"2023-12-01T12:01:20+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/"},"wordCount":1053,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-exceptions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/","url":"https:\/\/careerkarma.com\/blog\/python-exceptions\/","name":"Python Exceptions: A Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg","datePublished":"2020-10-01T07:56:20+00:00","dateModified":"2023-12-01T12:01:20+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Exceptions are logical errors in a Python program. On Career Karma, learn more about what exceptions are and how to raise and handle exceptions.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-exceptions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/antonio-janeski-KpIpjje1Mxk-unsplash.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-exceptions\/#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 Exceptions: A 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\/23440","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=23440"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23440\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/22628"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=23440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=23440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=23440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}