{"id":12163,"date":"2020-08-20T09:47:02","date_gmt":"2020-08-20T16:47:02","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12163"},"modified":"2023-12-01T03:58:03","modified_gmt":"2023-12-01T11:58:03","slug":"python-deque-queue","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/","title":{"rendered":"Python Queue and Deque: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>Python queue is a built in library that allows you to create a list that uses the FIFO rule, first in first out. Python deque uses the opposite rule, LIFO queue, or last in first out. Both operate on stacks and queues.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>When you\u2019re working in Python, you may want to create a queue of items instead of a <a href=\"https:\/\/careerkarma.com\/blog\/python-list-comprehension\/\">list<\/a>. For example, let\u2019s say you were writing a program that tracks registrations to a conference. When we add someone to the list, you want to place them at the back of the queue, and then you want them to advance through the queue as people at the front start to get in.<\/p>\n\n\n\n<p>There is a built-in library in Python designed to help you with these types of problems: queues. Queues are similar to stacks in Python, with the main difference being that with a queue, you remove the item least recently added. In a stack, on the other hand, you remove the item most recently added.<\/p>\n\n\n\n<p>In this tutorial, we are going to break down the basics of queues in Python and how you can implement one.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-69db01492861c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #000000;color:#000000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #000000;color:#000000\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69db01492861c\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#queue-primer\" >Queue Primer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#python-queue\" >Python Queue<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#python-deque-example\" >Python Deque Example<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"queue-primer\"><\/span>Queue Primer<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Helpful when working with a Python list, queues are useful when you want to get things out of a <a href=\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\">list<\/a> in the order that you put them in. To use our previous example, when you\u2019re at a conference, you should be placed at the back of the line when you first register. But as people on the list start to get in, you should move up further on the list.<\/p>\n\n\n\n<p><a href=\"https:\/\/careerkarma.com\/blog\/python-priority-queue\/\">Queues<\/a> are different from arrays and lists in that queues are not random access\u2014the data stored in a queue has a particular order. So if you want to add an item to a queue, it will be added to the end. This is called <code>first-in<\/code>, <code>first-out<\/code>, or a FIFO queue for short.<\/p>\n\n\n\n<p>In Python, you can use a standard list as a queue. However, lists can be quite slow if you are inserting and removing elements because changing elements at the start of the list requires moving all the other elements in the list down. Therefore, if you need to implement a first-in, last-out list, you should use a queue.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"python-queue\"><\/span>Python Queue<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So, how do you implement a queue in Python? In order to do so, we have to make use of the built-in queue library. The queue module includes a number of useful classes for queues, but for this tutorial we are going to focus on the <code>queue.Queue<\/code> class.<\/p>\n\n\n\n<p>Let\u2019s say that we are building a program that tracks people who want to go and see the latest movie at the local theater. We could use a queue to keep track of the waitlist of people who want to watch the movie.<\/p>\n\n\n\n<p>Firstly, we need to define our queue class. We can do that using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>from queue import Queue\nwaitlist = Queue()<\/pre><\/div>\n\n\n\n<p> Now we\u2019re ready to create our queue. The <code>put()<\/code> function allows data to be <code>put<\/code> into the queue. In the below code, we are going to add five people to the waitlist who have just signed up to see the movie: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>waitlist.put('Erin')\nwaitlist.put('Samantha')\nwaitlist.put('Joe')\nwaitlist.put('Martin')\nwaitlist.put('Helena')<\/pre><\/div>\n\n\n\n<p>Now we have added to the queue our five names. Erin is first in our queue, then Samantha, and so on until we reach Helena, who is last. We can demonstrate this by using the <code>get()<\/code> function, like so: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(waitlist.get())<\/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>Erin<\/pre><\/div>\n\n\n\n<p>As you can see, Erin is the first in our queue. If we wanted to print out the first two names that are in the queue, we would use the <code>get()<\/code> function twice: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(waitlist.get())\nprint(waitlist.get())<\/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>Erin\nSamantha<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"python-deque-example\"><\/span>Python Deque Example<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>But what if we want to add and remove a number of items from either end of our queue? This is where the deque function comes in. By using deque, we can create a double-ended queue where we can add and remove elements from the start or end of the queue. Deques are <code>last-in<\/code>,<code> first-out<\/code>, or LIFO for short.<\/p>\n\n\n\n<p>Let\u2019s use the same example as above: storing waitlisted names for a movie. Firstly, we\u2019ll declare our deque function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>from collections import deque\nwaitlist = deque()<\/pre><\/div>\n\n\n\n<p>Now we have initialized our deque, we can add our list of waitlisted names to our deque: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>waitlist.append('Erin')\nwaitlist.append('Samantha')\nwaitlist.append('Joe')\nwaitlist.append('Martin')\nwaitlist.append('Helena')<\/pre><\/div>\n\n\n\n<p>As you can see, we used the <code>append()<\/code> function to put an item into our queue. To see the values stored in our waitlist, we can use the following code: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(waitlist)<\/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>deque(['Erin', 'Samantha', 'Joe', 'Martin', 'Helena'])<\/pre><\/div>\n\n\n\n<p>As you can see, our data has been stored in the order we inserted it into our deque. But what if we want to remove the first item from our queue? We can use the <code>popleft()<\/code> function to accomplish this goal. Here\u2019s an example: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>waitlist.popleft()\nprint(waitlist)<\/pre><\/div>\n\n\n\n<p>Our code has removed the first item in our list &#8212; <code>Erin<\/code> &#8212; and returns the following: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>deque(['Samantha', 'Joe', 'Martin', 'Helena'])<\/pre><\/div>\n\n\n\n<p>If we want to remove all of the items in our deque, we can use the clear() function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>deque.clear()\nprint(waitlist)<\/pre><\/div>\n\n\n\n<p>The result of our code is as follows: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>deque([])<\/pre><\/div>\n\n\n\n<p>As you can see, our deque is empty, but the object still exists.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>That\u2019s it! In this article, we have discussed how queues are a type of data structure that allows you to adopt a first-in, first-out storage approach to storing data. One example use of a queue would be to keep a waitlist for a new product.<\/p>\n\n\n\n<p>We also discussed how you could use deque to create a double-ended queue where you can add and remove elements from your queue. Now you\u2019re ready to start writing your own queries and deques!<\/p>\n\n\n\n<p><strong><em>Python is used in a variety of professional programming environments. Download the <\/em><\/strong><a href=\"https:\/\/careerkarma.com\/\"><strong><em>free Career Karma app<\/em><\/strong><\/a><strong><em> today to learn about how Python can help you break into your dream career in tech!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"Python queue is a built in library that allows you to create a list that uses the FIFO rule, first in first out. Python deque uses the opposite rule, LIFO queue, or last in first out. Both operate on stacks and queues. When you\u2019re working in Python, you may want to create a queue of&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-12163","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 Queue and Deque: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Queues allow Python coders to store data in a first-in, first-out order. Learn how to use queues and deques 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-deque-queue\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Queue and Deque: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Queues allow Python coders to store data in a first-in, first-out order. Learn how to use queues and deques in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-deque-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-08-20T16:47:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:58:03+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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Queue and Deque: A Step-By-Step Guide\",\"datePublished\":\"2020-08-20T16:47:02+00:00\",\"dateModified\":\"2023-12-01T11:58:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/\"},\"wordCount\":953,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#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-deque-queue\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/\",\"name\":\"Python Queue and Deque: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg\",\"datePublished\":\"2020-08-20T16:47:02+00:00\",\"dateModified\":\"2023-12-01T11:58:03+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Queues allow Python coders to store data in a first-in, first-out order. Learn how to use queues and deques in this article.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#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-deque-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 Queue and Deque: 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 Queue and Deque: A Step-By-Step Guide | Career Karma","description":"Queues allow Python coders to store data in a first-in, first-out order. Learn how to use queues and deques 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-deque-queue\/","og_locale":"en_US","og_type":"article","og_title":"Python Queue and Deque: A Step-By-Step Guide","og_description":"Queues allow Python coders to store data in a first-in, first-out order. Learn how to use queues and deques in this article.","og_url":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-08-20T16:47:02+00:00","article_modified_time":"2023-12-01T11:58:03+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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Queue and Deque: A Step-By-Step Guide","datePublished":"2020-08-20T16:47:02+00:00","dateModified":"2023-12-01T11:58:03+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/"},"wordCount":953,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#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-deque-queue\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/","url":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/","name":"Python Queue and Deque: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/PYTHON-ZIP.jpg","datePublished":"2020-08-20T16:47:02+00:00","dateModified":"2023-12-01T11:58:03+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Queues allow Python coders to store data in a first-in, first-out order. Learn how to use queues and deques in this article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-deque-queue\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-deque-queue\/#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-deque-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 Queue and Deque: 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\/12163","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=12163"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12163\/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=12163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}