{"id":10140,"date":"2021-03-23T14:08:52","date_gmt":"2021-03-23T08:38:52","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=10140"},"modified":"2026-07-13T12:32:50","modified_gmt":"2026-07-13T07:02:50","slug":"python-list-pop","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/python-list-pop\/","title":{"rendered":"Python list.pop(): Remove and Return Items Safely"},"content":{"rendered":"<p><strong>Quick answer:<\/strong> list.pop() removes and returns one item, using the last item when no index is supplied. It is a natural stack operation; repeated pop(0) calls shift the remaining list and are usually better expressed with collections.deque.<\/p>\n<figure class=\"pythonpool-article-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop.png\" alt=\"Python Pool infographic explaining list pop index defaults negative indexes stacks queues and empty lists\" width=\"1536\" height=\"1024\" loading=\"lazy\" decoding=\"async\"><figcaption>list.pop() removes and returns one item; the default last-item behavior is useful for stacks, while front removals have a different performance tradeoff.<\/figcaption><\/figure>\n<p><code>list.pop()<\/code> removes an item from a Python list and returns that item. If you call it without an argument, it removes the last item. If you pass an index, it removes the item at that position.<\/p>\n<p>The two details that matter most are safety and intent: <code>pop()<\/code> changes the original list, and it raises <code>IndexError<\/code> if the list is empty or the index is invalid.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" 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: #990303;color:#990303\" 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><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Basic_listpop_Syntax\" >Basic list.pop() Syntax<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Pop_an_Item_by_Index\" >Pop an Item by Index<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Pop_the_First_Item\" >Pop the First Item<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Handle_Empty_Lists_Safely\" >Handle Empty Lists Safely<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Use_pop_as_a_Stack\" >Use pop() as a Stack<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Pop_from_a_Nested_List\" >Pop from a Nested List<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#pop_vs_remove_vs_del\" >pop() vs remove() vs del<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Pop_While_Iterating\" >Pop While Iterating<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Common_Mistakes\" >Common Mistakes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#When_Not_to_Use_pop\" >When Not to Use pop()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#FAQs\" >FAQs<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#What_does_listpop_return\" >What does list.pop() return?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#What_happens_if_I_call_pop_on_an_empty_list\" >What happens if I call pop() on an empty list?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Does_pop_remove_the_first_or_last_item\" >Does pop() remove the first or last item?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Pop_The_Last_Item\" >Pop The Last Item<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Use_An_Index\" >Use An Index<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Handle_Empty_Lists\" >Handle Empty Lists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Choose_deque_For_Front_Removal\" >Choose deque For Front Removal<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Frequently_Asked_Questions\" >Frequently Asked Questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#What_does_listpop_do_in_Python\" >What does list.pop() do in Python?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#What_happens_when_pop_is_called_on_an_empty_list\" >What happens when pop() is called on an empty list?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Can_listpop_remove_the_first_item\" >Can list.pop() remove the first item?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/#Does_pop_mutate_the_original_list\" >Does pop() mutate the original list?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Basic_listpop_Syntax\"><\/span>Basic list.pop() Syntax<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Python documents <code>pop()<\/code> in the official <a href=\"https:\/\/docs.python.org\/3\/tutorial\/datastructures.html#more-on-lists\">list methods<\/a> section. The default index is <code>-1<\/code>, so the last item is removed when no argument is passed.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">items = [\"red\", \"green\", \"blue\"]\nremoved = items.pop()\n\nprint(removed)\nprint(items)\n<\/code><\/pre>\n<\/div>\n<p>Use this pattern when you need both the removed value and the shortened list. If you only need to read the last value without changing the list, use <code>items[-1]<\/code> instead.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Pop_an_Item_by_Index\"><\/span>Pop an Item by Index<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Pass an index to remove a specific item. Python lists use zero-based indexes, so index <code>0<\/code> is the first item.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">items = [\"red\", \"green\", \"blue\"]\nremoved = items.pop(1)\n\nprint(removed)\nprint(items)\n<\/code><\/pre>\n<\/div>\n<p>For deeper indexing rules and boundary mistakes, see PythonPool&#8217;s <a href=\"https:\/\/www.pythonpool.com\/python-list-index-out-of-range\/\">list index out of range<\/a> guide.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Pop_the_First_Item\"><\/span>Pop the First Item<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><code>pop(0)<\/code> removes the first item, but it shifts the remaining items left. That is fine for small lists, but repeated front removal can be inefficient for large lists.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">queue = [\"task1\", \"task2\", \"task3\"]\nfirst = queue.pop(0)\n\nprint(first)\nprint(queue)\n<\/code><\/pre>\n<\/div>\n<p>If your program repeatedly removes from the front, consider whether a different data structure would be clearer. Python&#8217;s <a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#mutable-sequence-types\">mutable sequence<\/a> docs are useful for understanding which list operations mutate the sequence.<\/p>\n<p><!-- Python Pool visual layout repair 2026-07-13 --><\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/list-pop-last-b199.png\" alt=\"Python Pool infographic showing a list, pop, last item, and shortened list\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>list.pop() removes and returns the last item by default.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Handle_Empty_Lists_Safely\"><\/span>Handle Empty Lists Safely<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Calling <code>pop()<\/code> on an empty list raises <code>IndexError<\/code>. Python&#8217;s official <a href=\"https:\/\/docs.python.org\/3\/library\/exceptions.html#IndexError\">IndexError<\/a> docs describe this as an invalid sequence index.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">items = []\n\nif items:\n    removed = items.pop()\nelse:\n    removed = None\n\nprint(removed)\n<\/code><\/pre>\n<\/div>\n<p>Use this check when an empty list is a normal possibility. If an empty list means your earlier logic is wrong, fix the earlier logic instead of hiding the error.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Use_pop_as_a_Stack\"><\/span>Use pop() as a Stack<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A list works naturally as a simple stack: append items to the end, then pop them from the end. Both operations are easy to read.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">stack = []\nstack.append(\"open file\")\nstack.append(\"read data\")\nstack.append(\"close file\")\n\nwhile stack:\n    print(stack.pop())\n<\/code><\/pre>\n<\/div>\n<p>This last-in, first-out pattern is one of the most common uses of <code>pop()<\/code>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Pop_from_a_Nested_List\"><\/span>Pop from a Nested List<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For nested lists, check that the outer row exists before popping from the inner list.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">matrix = [[1, 2], [3, 4], []]\nrow = 0\n\nif row < len(matrix) and matrix[row]:\n    value = matrix[row].pop()\nelse:\n    value = None\n\nprint(value)\nprint(matrix)\n<\/code><\/pre>\n<\/div>\n<p>For more nested-list examples, read PythonPool's <a href=\"https:\/\/www.pythonpool.com\/python-2d-list\/\">Python 2D list<\/a> guide.<\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/list-pop-index-b199.png\" alt=\"Python Pool infographic mapping a list index through pop to removed item and remaining list\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Pass an index to remove and return a specific list item.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"pop_vs_remove_vs_del\"><\/span>pop() vs remove() vs del<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"pythonpool-table-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<table>\n<thead>\n<tr>\n<th>Operation<\/th>\n<th>Use it when<\/th>\n<th>Returns value?<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>pop(index)<\/code><\/td>\n<td>You know the position and need the removed item<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td><code>remove(value)<\/code><\/td>\n<td>You know the value and want to remove its first match<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td><code>del items[index]<\/code><\/td>\n<td>You know the position and do not need the removed item<\/td>\n<td>No<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Pop_While_Iterating\"><\/span>Pop While Iterating<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Be careful when removing items while looping over the same list. Mutating the list changes indexes and can skip values. Build a new list when filtering is the real goal.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">numbers = [1, 2, 3, 4, 5]\neven_numbers = [number for number in numbers if number % 2 == 0]\n\nprint(even_numbers)\nprint(numbers)\n<\/code><\/pre>\n<\/div>\n<p>If you need a copy before changing a list, PythonPool's <a href=\"https:\/\/www.pythonpool.com\/python-copy-list\/\">copy list<\/a> guide covers shallow copies, slicing, and <code>deepcopy()<\/code>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Common_Mistakes\"><\/span>Common Mistakes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Calling <code>pop()<\/code> on an empty list.<\/li>\n<li>Using an index equal to <code>len(items)<\/code>, which is outside the list.<\/li>\n<li>Expecting <code>pop()<\/code> to leave the original list unchanged.<\/li>\n<li>Using repeated <code>pop(0)<\/code> on large lists without considering performance.<\/li>\n<li>Removing items from a list while iterating over it by index.<\/li>\n<\/ul>\n<p>If your list comes from files in a folder, the refreshed <a href=\"https:\/\/www.pythonpool.com\/python-listdir\/\">os.listdir()<\/a> guide may also help.<\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/list-pop-stack-b199.png\" alt=\"Python Pool infographic comparing append, pop, push, LIFO, and stack state\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>append plus pop provides a simple last-in, first-out stack.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"When_Not_to_Use_pop\"><\/span>When Not to Use pop()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Do not use <code>pop()<\/code> when the code only needs to inspect a value. Direct indexing or slicing is clearer for read-only access. Python's <a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#common-sequence-operations\">common sequence operations<\/a> documentation covers indexing, slicing, membership tests, and length checks. Those operations keep the list intact, while <code>pop()<\/code> removes data. This distinction matters in debugging because a later line may fail only because an earlier <code>pop()<\/code> shortened the list.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"What_does_listpop_return\"><\/span>What does list.pop() return?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It returns the item it removes from the list.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_happens_if_I_call_pop_on_an_empty_list\"><\/span>What happens if I call pop() on an empty list?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Python raises <code>IndexError<\/code>. Check <code>if items:<\/code> before popping when an empty list is possible.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Does_pop_remove_the_first_or_last_item\"><\/span>Does pop() remove the first or last item?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Without an argument, <code>pop()<\/code> removes the last item. Use <code>pop(0)<\/code> to remove the first item.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Pop_The_Last_Item\"><\/span>Pop The Last Item<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The no-argument form removes the last item and returns it. This gives a list last-in-first-out stack behavior with append() and pop().<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">tasks = [\"parse\", \"validate\", \"save\"]\nwhile tasks:\n    task = tasks.pop()\n    print(\"running\", task)<\/code><\/pre>\n<\/div>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/list-pop-check-b199.png\" alt=\"Python Pool infographic testing empty lists, invalid indexes, mutation, return values, and validation\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Check empty input, invalid indexes, mutation timing, and use of the returned item.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Use_An_Index\"><\/span>Use An Index<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A non-negative index removes that position, while a negative index counts from the end. The list is mutated in either case, so keep the returned value if it is needed later.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">values = [\"a\", \"b\", \"c\", \"d\"]\nlast = values.pop()\nfirst = values.pop(0)\nprint(first, last, values)<\/code><\/pre>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Handle_Empty_Lists\"><\/span>Handle Empty Lists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Calling pop() on an empty list raises IndexError. A loop condition is often clearer than catching the exception, while a boundary API may catch it and convert it to a domain-specific result.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">def take_last(values):\n    if not values:\n        return None\n    return values.pop()\n\nitems = []\nprint(take_last(items))<\/code><\/pre>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Choose_deque_For_Front_Removal\"><\/span>Choose deque For Front Removal<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>pop(0) is useful occasionally, but each front removal shifts later elements. deque.popleft() is designed for queue behavior and keeps the operation efficient as the collection grows.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">from collections import deque\n\nqueue = deque([\"first\", \"second\", \"third\"])\nwhile queue:\n    print(queue.popleft())<\/code><\/pre>\n<\/div>\n<p>The official <a href=\"https:\/\/docs.python.org\/3\/tutorial\/datastructures.html#more-on-lists\">list documentation<\/a> defines pop(index) and its IndexError behavior. Match the method to whether the workload is a stack, an occasional indexed removal, or a queue.<\/p>\n<p>For related sequence and queue patterns, compare <a href=\"https:\/\/www.pythonpool.com\/python-heapq\/\">heapq priority queues<\/a>, <a href=\"https:\/\/www.pythonpool.com\/python-combine-lists\/\">combining lists<\/a>, and <a href=\"https:\/\/www.pythonpool.com\/python-ordereddict\/\">ordered mappings<\/a> when list mutation is no longer the whole data-structure contract.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions\"><\/span>Frequently Asked Questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"What_does_listpop_do_in_Python\"><\/span>What does list.pop() do in Python?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It removes and returns the item at an index, defaulting to the last item when no index is supplied.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_happens_when_pop_is_called_on_an_empty_list\"><\/span>What happens when pop() is called on an empty list?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It raises IndexError, so check the list or handle the exception when emptiness is possible.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_listpop_remove_the_first_item\"><\/span>Can list.pop() remove the first item?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes, pop(0) removes and returns the first item, but deque.popleft() is generally a better fit for repeated front removals.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Does_pop_mutate_the_original_list\"><\/span>Does pop() mutate the original list?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes. The list becomes shorter and the removed value is returned to the caller.<\/p>\n<p><script type=\"application\/ld+json\">{\"@context\":\"https:\/\/schema.org\",\"@type\":\"FAQPage\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"What does list.pop() do in Python?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It removes and returns the item at an index, defaulting to the last item when no index is supplied.\"}},{\"@type\":\"Question\",\"name\":\"What happens when pop() is called on an empty list?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It raises IndexError, so check the list or handle the exception when emptiness is possible.\"}},{\"@type\":\"Question\",\"name\":\"Can list.pop() remove the first item?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes, pop(0) removes and returns the first item, but deque.popleft() is generally a better fit for repeated front removals.\"}},{\"@type\":\"Question\",\"name\":\"Does pop() mutate the original list?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. The list becomes shorter and the removed value is returned to the caller.\"}}]}<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.<\/p>\n","protected":false},"author":17,"featured_media":32356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[3764,3766,3768,3767,3763,3765],"class_list":["post-10140","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-list-pop-python","tag-pop-from-list-python","tag-pop-python-list","tag-python-list-pop-first","tag-python-list-pop-last","tag-python-pop-list","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v28.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python list.pop(): Remove and Return Items Safely<\/title>\n<meta name=\"description\" content=\"Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/python-list-pop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python list.pop(): Remove and Return Items Safely\" \/>\n<meta property=\"og:description\" content=\"Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-list-pop\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-23T08:38:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-13T07:02:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop.png\" \/>\n<meta name=\"author\" content=\"Siddharth Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Python Pool\" \/>\n<meta name=\"twitter:description\" content=\"Practical Python tutorials, error fixes, code examples, and project guides.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop.png\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Siddharth Jain\" \/>\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:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/\"},\"author\":{\"name\":\"Siddharth Jain\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/person\\\/75a3240fabe5ea90200777a9d8d3b4fa\"},\"headline\":\"Python list.pop(): Remove and Return Items Safely\",\"datePublished\":\"2021-03-23T08:38:52+00:00\",\"dateModified\":\"2026-07-13T07:02:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/\"},\"wordCount\":1020,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/python-list-pop-guide-pythonpool.png\",\"keywords\":[\"list pop python\",\"pop from list python\",\"pop python list\",\"python list pop first\",\"python list pop last\",\"python pop list\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/\",\"name\":\"Python list.pop(): Remove and Return Items Safely\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/python-list-pop-guide-pythonpool.png\",\"datePublished\":\"2021-03-23T08:38:52+00:00\",\"dateModified\":\"2026-07-13T07:02:50+00:00\",\"description\":\"Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/python-list-pop-guide-pythonpool.png\",\"contentUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/python-list-pop-guide-pythonpool.png\",\"width\":1350,\"height\":650,\"caption\":\"Python list pop guide showing remove return last item index pop stack and IndexError safe checks\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/python-list-pop\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pythonpool.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python list.pop(): Remove and Return Items Safely\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/\",\"name\":\"Python Pool\",\"description\":\"Practical Python tutorials, error fixes, code examples, and project guides.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pythonpool.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/aa.png\",\"contentUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/pythonpool\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/person\\\/75a3240fabe5ea90200777a9d8d3b4fa\",\"name\":\"Siddharth Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g\",\"caption\":\"Siddharth Jain\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python list.pop(): Remove and Return Items Safely","description":"Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.","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:\/\/www.pythonpool.com\/python-list-pop\/","og_locale":"en_US","og_type":"article","og_title":"Python list.pop(): Remove and Return Items Safely","og_description":"Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.","og_url":"https:\/\/www.pythonpool.com\/python-list-pop\/","og_site_name":"Python Pool","article_published_time":"2021-03-23T08:38:52+00:00","article_modified_time":"2026-07-13T07:02:50+00:00","og_image":[{"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop.png","type":"","width":"","height":""}],"author":"Siddharth Jain","twitter_card":"summary_large_image","twitter_title":"Python Pool","twitter_description":"Practical Python tutorials, error fixes, code examples, and project guides.","twitter_image":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop.png","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Siddharth Jain","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/python-list-pop\/"},"author":{"name":"Siddharth Jain","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa"},"headline":"Python list.pop(): Remove and Return Items Safely","datePublished":"2021-03-23T08:38:52+00:00","dateModified":"2026-07-13T07:02:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-list-pop\/"},"wordCount":1020,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop-guide-pythonpool.png","keywords":["list pop python","pop from list python","pop python list","python list pop first","python list pop last","python pop list"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/python-list-pop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/python-list-pop\/","url":"https:\/\/www.pythonpool.com\/python-list-pop\/","name":"Python list.pop(): Remove and Return Items Safely","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop-guide-pythonpool.png","datePublished":"2021-03-23T08:38:52+00:00","dateModified":"2026-07-13T07:02:50+00:00","description":"Use Python list.pop() with indexes, stacks, queues, empty-list checks, negative indexes, and alternatives that match the workload.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/python-list-pop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop-guide-pythonpool.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/python-list-pop-guide-pythonpool.png","width":1350,"height":650,"caption":"Python list pop guide showing remove return last item index pop stack and IndexError safe checks"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/python-list-pop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python list.pop(): Remove and Return Items Safely"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Practical Python tutorials, error fixes, code examples, and project guides.","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa","name":"Siddharth Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g","caption":"Siddharth Jain"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/10140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=10140"}],"version-history":[{"count":26,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/10140\/revisions"}],"predecessor-version":[{"id":41608,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/10140\/revisions\/41608"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/32356"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=10140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=10140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=10140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}