🌐
W3Schools
w3schools.com › python › ref_list_pop.asp
Python List pop() Method
Remove List Duplicates Reverse ... Interview Q&A Python Bootcamp Python Training ... The pop() method removes the element at the specified position....
🌐
Reddit
reddit.com › r/learnpython › list.pop and list.pop()
r/learnpython on Reddit: list.pop and list.pop()
June 27, 2024 -

This feels like one of those python weird things. I am interested in explanations.

If I have a list=[1,2,3,4] and I do list.pop() the result is list=[1,2,3].

Perfect, just what I wanted.

However, if I am not careful and instead do list.pop--note there are no parentheses this time--I get no syntax error or warning and nothing happens, leading me to a strange debug session.

In the repl, if I do l.pop it just identifies it as a built-in method of list object at 0xwhatever. That's useful, but why is there not at least a runtime warning when I make this mistake in my code?

🌐
Programiz
programiz.com › python-programming › methods › list › pop
Python List pop()
The pop() method returns the item present at the given index. This item is also removed from the list. # programming languages list languages = ['Python', 'Java', 'C++', 'French', 'C']
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-pop-method
Python List pop() Method - GeeksforGeeks
3 days ago - DSA Python · Data Science · NumPy · Pandas · Practice · Django · Flask · Last Updated : 17 Jul, 2026 · pop() method removes an element from a list and returns the removed value.
🌐
Mimo
mimo.org › glossary › python › pop()
Python Pop Method: Essential Data Manipulation techniques
In Python, pop() is a list method that removes and returns an element of a list. With an argument, pop() removes and returns the item at the specified index (starting from 0).
🌐
DataCamp
datacamp.com › tutorial › python-pop
How to Use the Python pop() Method | DataCamp
July 31, 2024 - Learn how to use Python's pop() method to remove elements from lists and dictionaries. Learn to avoid common errors like IndexError and KeyError.
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.6 documentation
The list methods make it very easy ... add an item to the top of the stack, use append(). To retrieve an item from the top of the stack, use pop() without an explicit index....
🌐
Tutorialspoint
tutorialspoint.com › python › list_pop.htm
Python List pop() Method
The Python List pop() method removes and returns the last object from the list, by default. However, the method also accepts an optional index argument and the element at the index is removed from the list.
Find elsewhere
🌐
Codecademy
codecademy.com › docs › python › lists › .pop()
Python | Lists | .pop() | Codecademy
May 26, 2025 - The .pop() method in Python removes an element from a list at a specified index and returns that element. The .pop() method directly modifies the original list by removing the element at the given position.
🌐
freeCodeCamp
freecodecamp.org › news › python-pop-how-to-pop-from-a-list-or-an-array-in-python
Python .pop() – How to Pop from a List or an Array in Python
March 1, 2022 - Besides just removing the item, pop() also returns it. This is helpful if you want to save and store that item in a variable for later use. #list of programming languages programming_languages = ["Python", "Java", "JavaScript"] #print initial list print(programming_languages) #remove last item, which is "JavaScript", and store it in a variable front_end_language = programming_languages.pop() #print list again print(programming_languages) #print the item that was removed print(front_end_language) #output #['Python', 'Java', 'JavaScript'] #['Python', 'Java'] #JavaScript
🌐
w3resource
w3resource.com › python › list › list_pop.php
Python List pop() Method
April 14, 2026 - The pop() method removes and returns an item from a list at a specified position. 2. What happens if no index is specified in Python list?
🌐
How to Use Linux
howtouselinux.com › home › understanding python list pop method
Understanding Python List Pop Method - howtouselinux
October 9, 2025 - The Python list pop method is a built-in method that removes the item at the given index from the list. It returns the removed item. The index is optional. If the index is not given, then the last element is popped out and removed.If the index passed to the method is not in range, it […]
🌐
Python Guides
pythonguides.com › python-list-pop-method
Python pop() List Method
October 13, 2025 - This is one of the most common ways I use pop() when managing dynamic lists in automation scripts. Sometimes, you may want to remove an item from a specific position in the list rather than the last one. Python’s pop() method allows you to specify the index of the element you want to remove.
🌐
Hyperskill
hyperskill.org › university › python › pop-in-python
Pop() in Python
October 14, 2025 - The Python pop() function deletes an element from a list at an index or if no index is specified, the last item. It comes in handy for removing items, from a list without changing the order of elements.
🌐
DigitalOcean
digitalocean.com › community › tutorials › pop-python
How to Use `.pop()` in Python Lists and Dictionaries | DigitalOcean
July 24, 2025 - Python’s .pop() method is a powerful and flexible built-in function that allows you to remove and return elements from both lists and dictionaries. This method is especially useful in scenarios where you need to both extract and delete items in a single, efficient operation.
🌐
AskPython
askpython.com › python › list › python-list-pop
How to Use The Python List pop() Method - AskPython
August 6, 2022 - This is a method of the List object type, so every list object will have this method. ... This is the default invocation, and will simply pop the last item from the list.
Top answer
1 of 3
18

Are your lists large? If so, use ifilter from itertools to filter out elements that you don't want lazily (with no up front cost).

Lists not so large? Just use a list comprehension:

 newlist = [x for x in oldlist if x not in ['a', 'c'] ]

This will create a new copy of the list. This is not generally an issue for efficiency unless you really care about memory consumption.

As a happy medium of syntax convenience and laziness ( = efficiency for large lists), you can construct a generator rather than a list by using ( ) instead of [ ]:

interestingelts = (x for x in oldlist if x not in ['a', 'c'])

After this, you can iterate over interestingelts, but you can't index into it:

 for y in interestingelts:    # ok
    print y

 print interestingelts[0]     # not ok: generator allows sequential access only
2 of 3
15

You want a list comprehension:

L = [c for c in L if c not in ['a', 'c']]

Or, if you really don't want to create a copy, go backwards:

for i in reversed(range(len(L))):
    if L[i] in ['a', 'c']:
        L.pop(i)    # del L[i] is more efficient

Thanks to ncoghlan for reversed() & phooji for del L[i] suggestions. (I decided to leave it as L.pop(i), since that's how the question was initially formulated.)

Also, as J.S. Sebastian correctly points out, going backwards is space efficient but time inefficient; most of the time a list comprehension or generator (L = (...) instead of L = [...]) is best.

Edit:

Ok, so since people seem to want something less ridiculously slow than the reversed method above (I can't imagine why... :) here's an order-preserving, in-place filter that should differ in speed from a list comprehension only by a constant. (This is akin to what I'd do if I wanted to filter a string in c.)

write_i = 0
for read_i in range(len(L)):
    L[write_i] = L[read_i]
    if L[read_i] not in ['a', 'c']:
         write_i += 1

del L[write_i:]
print L
# output: ['b', 'd']
🌐
Finxter
blog.finxter.com › home › learn python blog › python list pop()
Python List pop() – Be on the Right Side of Change
June 19, 2021 - This tutorial shows you everything ... programming language. Definition and Usage: The list.pop() method removes and returns the last element from an existing list....
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › python list pop() method: remove and return items
Python List pop() Method: pop by Index, Last Item, First Item, and Errors (2026)
January 9, 2024 - Tested on: Python 3.13.3; kernel 6.14.0-37-generic. list.pop([i]) removes the item at index i, returns it, and mutates the same list object. If you omit i, Python uses -1 (the last element). The list becomes shorter by one.