{"id":15952,"date":"2020-12-01T00:16:46","date_gmt":"2020-12-01T08:16:46","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=15952"},"modified":"2023-12-01T04:05:06","modified_gmt":"2023-12-01T12:05:06","slug":"python-priority-queue","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/","title":{"rendered":"Python Priority Queue: A Guide"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Python Priority Queue: A Guide<\/h2>\n\n\n\n<p><em>A Python priority queue stores data in a particular order. There are two ways to implement a priority queue in Python: using the queue class and using the heapq module.<\/em><\/p>\n\n\n\n<p>You may want to order data based on the values of each item in the list. For instance, you may want the highest value to appear first in the list, and the lowest value to appear last in the list.<\/p>\n\n\n\n<p>That\u2019s where priority queues come in. A priority queue is a data structure that stores data based on the value of its keys in ascending order. This allows you to easily access the smallest and largest value in the queue.<\/p>\n\n\n\n<p>This tutorial will discuss why you should not use a list to create priority queues. We will show you two more efficient approaches you can use to create a Python priority queue.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Python Priority Queue?<\/h2>\n\n\n\n<p>Priority queues are a modified version of a queue that stores data in order of which element has the highest priority. The priority of each element in a priority queue is decided depending on the value of the element.<\/p>\n\n\n\n<p>In computer science, queues are data structures that store items in the first-in, first-out (FIFO) order. There are a few scenarios where using this structure can be helpful.<\/p>\n\n\n\n<p>For instance, suppose you are building an order tracking app for a restaurant. The person who places an order first should be served before the people who place their order next. To keep track of orders, you would want to use a queue.<\/p>\n\n\n\n<p>There are two ways to define a priority queue in Python:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Using the PriorityQueue queue class<\/li><li>Using the heapq module<\/li><\/ul>\n\n\n\n<p>You can define a priority queue using a list structure. But, this strategy is less efficient than using the PriorityQueue queue class or the heapq module.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Priority Queue Python: queue.PriorityQueue<\/h2>\n\n\n\n<p>The <em>queue.PriorityQueue<\/em> class creates a Python priority queue. This class is part of the Python queue library. You need to import the queue library to use this class. To retrieve an item from a PriorityQueue, you can use the get() method.<\/p>\n\n\n\n<p>To access the PriorityQueue class, we need to import it into our code, which we can do using this <a href=\"https:\/\/careerkarma.com\/blog\/python-import\/\">Python import statement<\/a>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>from queue import PriorityQueue<\/pre><\/div>\n\n\n\n<p>Suppose we want to create a priority queue for ticket holders at a local concert. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>from queue import PriorityQueue\n\nticket_holders = PriorityQueue()\n\nticket_holders.put((3, 'Paul'))\nticket_holders.put((1, 'Miles'))\nticket_holders.put((2, 'Dani'))\n\nwhile not ticket_holders.empty():\n\titem = ticket_holders.get()\n\tprint(item)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>(1, 'Miles')\n(2, 'Dani')\n(3, 'Paul')<\/pre><\/div>\n\n\n\n<p>In our code, we first import the PriorityQueue class from the <em>queue<\/em> library, then we initialize a priority queue called <em>ticket_holders<\/em>. Next, we insert three tuples into our priority queue, which store the ticket numbers and names associated with a ticket.<\/p>\n\n\n\n<p>We use a <a href=\"https:\/\/careerkarma.com\/blog\/do-while-python\/\">Python while loop<\/a> to run through each item in the <em>ticket_holders<\/em> priority queue. Then, we retrieve that item using <em>get()<\/em>.<\/p>\n\n\n\n<p>The <em>queue.PriorityQueue<\/em> method is efficient and easy to use, which makes it a great choice for when you need to create a priority queue.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Priority Queue Python heapq Module<\/h2>\n\n\n\n<p>The heapq module lets you define a Python priority queue. A heapq data structure removes items in order of their priority. The lowest value has the lowest priority and he highest value has the highest priority in the heapq structure.<\/p>\n\n\n\n<p>Before we can use the heapq module, we must first import it into our code using the following import statement:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import heapq<\/pre><\/div>\n\n\n\n<p>Let\u2019s return to our earlier example. Suppose we want to create a priority queue to store information about ticket holders at a concert. We could do so using the heapq module and this program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import heapq\n\nticket_holders = []\n\nheapq.heappush(ticket_holders, (3, 'Paul'))\nheapq.heappush(ticket_holders, (1, 'Miles'))\nheapq.heappush(ticket_holders, (2, 'Dani'))\n\nwhile ticket_holders:\n\titem = heapq.heappop(ticket_holders)\n\tprint(item)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>(1, 'Miles')\n(2, 'Dani')\n(3, 'Paul')<\/pre><\/div>\n\n\n\n<p>First, we imported the heapq library, and then we initialized a <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> called <em>ticket_holders<\/em>. We used the <em>heappush()<\/em> method to push three tuples to our priority queue. This queue stores the ticket numbers for each ticket holder and the name of each ticket holder.<\/p>\n\n\n\n<p>We then created a while loop which loops through each item in our priority queue. This loop removes the item at the top of the queue using <em>heappop()<\/em>. Then, the removed item is printed to the console. As you can see, all the items in our queue are printed out in order of their priority.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why You Should Not Keep a List<\/h2>\n\n\n\n<p>Technically, you can create a priority queue using the <a href=\"https:\/\/careerkarma.com\/blog\/python-array\/\">Python list data structure<\/a>. To do so, you would create a list, then order it in ascending order.<\/p>\n\n\n\n<p>However, this is a relatively inefficient way of maintaining a priority queue. As you change items in the list, you would need to re-order the list, which takes up time.<\/p>\n\n\n\n<p>You can use a traditional list as a priority queue if you only need to store a few values. But, if you are looking to create a larger queue, lists are not a good option.<\/p>\n\n\n\n<p>For reference, let\u2019s walk through an example of a priority queue using lists. Suppose we want to create a priority queue that stores the order of ticket holders who should be let into a concert first. We could use the following code to create this queue:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ticket_holders = []\n\nticket_holders.append((3, 'Paul'))\nticket_holders.append((1, 'Miles'))\nticket_holders.append((2, 'Dani'))\n\nticket_holders.sort(reverse=True)\n\nwhile ticket_holders:\n\titem = ticket_holders.pop()\n\tprint(item)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>(1, 'Miles')\n(2, 'Dani')\n(3, 'Paul')<\/pre><\/div>\n\n\n\n<p>We have created a list called <em>ticket_holders<\/em>, then we added three tuples to the list. Each tuple contained the ticket number of a ticket holder and their name. Then, we used the Python <em>sort()<\/em> function to sort our list of ticket holders in reverse order.<\/p>\n\n\n\n<p>We created a while loop that iterates through every item in the <em>ticket_holders<\/em> list and the item at the top of the list. Then, our code prints out the removed item to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The two most common to create a priority queue are to use the heapq module or the <em>queue.PriorityQueue<\/em> class. While you can technically use a list as a priority queue, this approach does not scale well.<\/p>\n\n\n\n<p>This tutorial discussed, with reference to examples, how to create a priority queue in Python. Now you\u2019re equipped with the knowledge you need to start creating your own priority queues like a Python professional!<\/p>\n\n\n\n<p>For more guidance on how to learn Python, check out our complete <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"Python Priority Queue: A Guide A Python priority queue stores data in a particular order. There are two ways to implement a priority queue in Python: using the queue class and using the heapq module. You may want to order data based on the values of each item in the list. For instance, you may&hellip;","protected":false},"author":240,"featured_media":15953,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-15952","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 Priority Queue: A Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Priority queues allow you to store data based on the priority of keys in a queue. On Career Karma, learn how to create a priority queue in Python.\" \/>\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-priority-queue\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Priority Queue: A Guide\" \/>\n<meta property=\"og:description\" content=\"Priority queues allow you to store data based on the priority of keys in a queue. On Career Karma, learn how to create a priority queue in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\" \/>\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-01T08:16:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.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=\"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-priority-queue\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Priority Queue: A Guide\",\"datePublished\":\"2020-12-01T08:16:46+00:00\",\"dateModified\":\"2023-12-01T12:05:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\"},\"wordCount\":1024,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\",\"name\":\"Python Priority Queue: A Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg\",\"datePublished\":\"2020-12-01T08:16:46+00:00\",\"dateModified\":\"2023-12-01T12:05:06+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Priority queues allow you to store data based on the priority of keys in a queue. On Career Karma, learn how to create a priority queue in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#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 Priority Queue: 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 Priority Queue: A Guide | Career Karma","description":"Priority queues allow you to store data based on the priority of keys in a queue. On Career Karma, learn how to create a priority queue in Python.","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-priority-queue\/","og_locale":"en_US","og_type":"article","og_title":"Python Priority Queue: A Guide","og_description":"Priority queues allow you to store data based on the priority of keys in a queue. On Career Karma, learn how to create a priority queue in Python.","og_url":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-01T08:16:46+00:00","article_modified_time":"2023-12-01T12:05:06+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.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-priority-queue\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Priority Queue: A Guide","datePublished":"2020-12-01T08:16:46+00:00","dateModified":"2023-12-01T12:05:06+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/"},"wordCount":1024,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-priority-queue\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/","url":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/","name":"Python Priority Queue: A Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg","datePublished":"2020-12-01T08:16:46+00:00","dateModified":"2023-12-01T12:05:06+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Priority queues allow you to store data based on the priority of keys in a queue. On Career Karma, learn how to create a priority queue in Python.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-priority-queue\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/arts-build-close-up-commerce-273230.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-priority-queue\/#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 Priority Queue: 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\/15952","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=15952"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/15952\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15953"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=15952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=15952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=15952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}