{"id":21059,"date":"2020-08-10T09:54:45","date_gmt":"2020-08-10T16:54:45","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=21059"},"modified":"2023-12-01T03:57:25","modified_gmt":"2023-12-01T11:57:25","slug":"python-local-variable-referenced-before-assignment","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/","title":{"rendered":"Python local variable referenced before assignment Solution"},"content":{"rendered":"\n<p>When you start introducing functions into your code, you\u2019re bound to encounter an UnboundLocalError at some point. This error is raised when you try to use a variable before it has been assigned in the <a href=\"https:\/\/careerkarma.com\/blog\/python-global-local-variables\/\">local context<\/a>.<br><\/p>\n\n\n\n<p>In this guide, we talk about what this error means and why it is raised. We walk through an example of this error in action to help you understand how you can solve it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-unboundlocalerror-local-variable-referenced-before-assignment\">What is UnboundLocalError: local variable referenced before assignment?<\/h2>\n\n\n\n<p>Trying to assign a value to a variable that does not have local scope can result in this error:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>UnboundLocalError: local variable referenced before assignment<\/pre><\/div>\n\n\n\n<p>Python has a simple rule to determine the scope of a variable. If a <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">variable<\/a> is assigned in a <a href=\"https:\/\/careerkarma.com\/blog\/python-functions\/\">function<\/a>, that variable is local. This is because it is assumed that when you define a variable inside a function you only need to access it inside that function.<br><\/p>\n\n\n\n<p>There are two variable scopes in Python: local and global. Global variables are accessible throughout an entire program; local variables are only accessible within the function in which they are originally defined.<br><\/p>\n\n\n\n<p>Let\u2019s take a look at how to solve this error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-an-example-scenario\">An Example Scenario<\/h2>\n\n\n\n<p>We&#8217;re going to write a program that calculates the grade a student has earned in class.<br><\/p>\n\n\n\n<p>We start by declaring two variables:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>numerical = 36\nletter = &quot;F&quot;<\/pre><\/div>\n\n\n\n<p>These variables store the numerical and letter grades a student has earned, respectively. By default, the value of \u201cletter\u201d is \u201cF\u201d. Next, we write a function that calculates a student\u2019s letter grade based on their numerical grade using an <a href=\"https:\/\/careerkarma.com\/blog\/python-if-else\/\">\u201cif\u201d statement<\/a>:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def calculate_grade(grade):\n\tif grade &gt; 80:\n\t\tletter = &quot;A&quot;\n\telif grade &gt; 70:\n\t\tletter = &quot;B&quot;\n\telif grade &gt; 60:\n\t\tletter = &quot;C&quot;\n\telif grade &gt; 50:\n\t\tletter = &quot;D&quot;\n\treturn letter<\/pre><\/div>\n\n\n\n<p>Finally, we call our function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(calculate_grade(numerical))<\/pre><\/div>\n\n\n\n<p>This line of code prints out the value returned by the <code>calculate_grade()<\/code> function to the console. We pass through one parameter into our function: numerical. This is the numerical value of the grade a student has earned.<br><\/p>\n\n\n\n<p>Let\u2019s run our code and see what happens:<\/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 15, in &lt;module&gt;\n\tprint(calculate_grade(numerical))\n  File &quot;main.py&quot;, line 13, in calculate_grade\n\treturn letter\nUnboundLocalError: local variable 'letter' referenced before assignment<\/pre><\/div>\n\n\n\n<p>An error has been raised.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-solution\">The Solution<\/h2>\n\n\n\n<p>Our code returns an error because we reference \u201cletter\u201d before we assign it.<br><\/p>\n\n\n\n<p>We have set the value of \u201cnumerical\u201d to 42. Our <code>if<\/code> statement does not set a value for any grade over 50. This means that when we call our <code>calculate_grade()<\/code> function, our return statement does not know the value to which we are referring.<br><\/p>\n\n\n\n<p>We do define \u201cletter\u201d at the start of our program. However, we define it in the global context. Python treats &#8220;return letter&#8221; as trying to return a local variable called &#8220;letter&#8221;, not a global variable.<br><\/p>\n\n\n\n<p>We solve this problem in two ways. First, we can add an <code>else<\/code> statement to our code. This ensures we declare \u201cletter\u201d before we try to return it:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def calculate_grade(grade):\n\tif grade &gt; 80:\n\t\tletter = &quot;A&quot;\n\telif grade &gt; 70:\n\t\tletter = &quot;B&quot;\n\telif grade &gt; 60:\n\t\tletter = &quot;C&quot;\n    elif grade &gt; 50:\n        letter = &quot;D&quot;\n    else:\n        letter = &quot;F&quot;\n    return letter<\/pre><\/div>\n\n\n\n<p>Let\u2019s try to run our code again:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>F<\/pre><\/div>\n\n\n\n<p>Our code successfully prints out the student\u2019s grade.<\/p>\n\n\n\n<p>If you are using an &#8220;if&#8221; statement where you declare a variable, you should make sure there is an &#8220;else&#8221; statement in place. This will make sure that even if none of your if statements evaluate to True, you can still set a value for the variable with which you are going to work.<\/p>\n\n\n\n<p>Alternatively, we could use the \u201cglobal\u201d keyword to make our global keyword available in the local context in our <code>calculate_grade()<\/code> function. However, this approach is likely to lead to more confusing code and other issues. In general, variables <strong>should not be declared using &#8220;global&#8221; unless absolutely necessary<\/strong>. Your first, and main, port of call should always be to make sure that a variable is correctly defined.<\/p>\n\n\n\n<p>In the example above, for instance, we did not check that the variable &#8220;letter&#8221; was defined in all use cases.<\/p>\n\n\n\n<p>That\u2019s it! We have fixed the local variable error in our code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>The UnboundLocalError: local variable referenced before assignment error is raised when you try to assign a value to a local variable before it has been declared. You can solve this error by ensuring that a local variable is declared before you assign it a value.<br><\/p>\n\n\n\n<p>Now you\u2019re ready to solve UnboundLocalError Python errors like a <a href=\"https:\/\/careerkarma.com\/blog\/python-projects-beginners\/\">professional developer<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"When you start introducing functions into your code, you\u2019re bound to encounter an UnboundLocalError at some point. This error is raised when you try to use a variable before it has been assigned in the local context. In this guide, we talk about what this error means and why it is raised. We walk through&hellip;","protected":false},"author":240,"featured_media":21060,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-21059","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.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python local variable referenced before assignment Solution | CK<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn about the Python local variable referenced before assignment error, how the error works, and how to solve the error.\" \/>\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-local-variable-referenced-before-assignment\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python local variable referenced before assignment Solution\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn about the Python local variable referenced before assignment error, how the error works, and how to solve the error.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/\" \/>\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-08-10T16:54:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:57:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/fabian-irsara-67l-QujB14w-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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python local variable referenced before assignment Solution\",\"datePublished\":\"2020-08-10T16:54:45+00:00\",\"dateModified\":\"2023-12-01T11:57:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/\"},\"wordCount\":665,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/fabian-irsara-67l-QujB14w-unsplash.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/\",\"name\":\"Python local variable referenced before assignment Solution | CK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/fabian-irsara-67l-QujB14w-unsplash.jpg\",\"datePublished\":\"2020-08-10T16:54:45+00:00\",\"dateModified\":\"2023-12-01T11:57:25+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn about the Python local variable referenced before assignment error, how the error works, and how to solve the error.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/fabian-irsara-67l-QujB14w-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/fabian-irsara-67l-QujB14w-unsplash.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-local-variable-referenced-before-assignment\\\/#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 local variable referenced before assignment Solution\"}]},{\"@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\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"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 local variable referenced before assignment Solution | CK","description":"On Career Karma, learn about the Python local variable referenced before assignment error, how the error works, and how to solve the error.","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-local-variable-referenced-before-assignment\/","og_locale":"en_US","og_type":"article","og_title":"Python local variable referenced before assignment Solution","og_description":"On Career Karma, learn about the Python local variable referenced before assignment error, how the error works, and how to solve the error.","og_url":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-08-10T16:54:45+00:00","article_modified_time":"2023-12-01T11:57:25+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/fabian-irsara-67l-QujB14w-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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python local variable referenced before assignment Solution","datePublished":"2020-08-10T16:54:45+00:00","dateModified":"2023-12-01T11:57:25+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/"},"wordCount":665,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/fabian-irsara-67l-QujB14w-unsplash.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/","url":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/","name":"Python local variable referenced before assignment Solution | CK","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/fabian-irsara-67l-QujB14w-unsplash.jpg","datePublished":"2020-08-10T16:54:45+00:00","dateModified":"2023-12-01T11:57:25+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn about the Python local variable referenced before assignment error, how the error works, and how to solve the error.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/fabian-irsara-67l-QujB14w-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/fabian-irsara-67l-QujB14w-unsplash.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-local-variable-referenced-before-assignment\/#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 local variable referenced before assignment Solution"}]},{"@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\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","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\/21059","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=21059"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/21059\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/21060"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=21059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=21059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=21059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}