From a performance point of view:

  • mylist = mylist[2:-2] and del mylist[:2];del mylist[-2:] are equivalent
  • they are around 3 times faster than the first solution for _ in range(2): mylist.pop(0); mylist.pop()

Code

iterations = 1000000
print timeit.timeit('''mylist=range(9)\nfor _ in range(2): mylist.pop(0); mylist.pop()''', number=iterations)/iterations
print timeit.timeit('''mylist=range(9)\nmylist = mylist[2:-2]''', number=iterations)/iterations
print timeit.timeit('''mylist=range(9)\ndel mylist[:2];del mylist[-2:]''', number=iterations)/iterations

output

1.07710313797e-06

3.44465017319e-07

3.49956989288e-07

Answer from mxdbld on Stack Overflow
๐ŸŒ
Python
bugs.python.org โ€บ issue9218
Issue 9218: pop multiple elements of a list at once - Python tracker
July 10, 2010 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide ยท This issue has been migrated to GitHub: https://github.com/python/cpython/issues/53464
Discussions

How do I pop multiple items from a queue? (python)
filter(lambda x: x < 50, xs) where xs is your collection of numbers. Documentation . More on reddit.com
๐ŸŒ r/CodingHelp
3
1
October 9, 2022
Why pop method removes two list at once?
Pop modifies the list. Here you remove an item from the list, and throw it away: guest.pop() Then you remove another item, and print it: print(f"{guest.pop()}") In your second example, you only call pop once, hence why only one item is removed. More on reddit.com
๐ŸŒ r/learnpython
27
16
December 17, 2023
python - How to remove multiple indexes from a list at the same time? - Stack Overflow
Say I have this list here: list = [a, b, c, d, e, f, g] How would I delete say indexes 2, 3, 4, and 5 at the same time? pop doesn't accept multiple values. How else do I do this? More on stackoverflow.com
๐ŸŒ stackoverflow.com
June 14, 2019
How do I add multiple things to a pop list in Python?
Pop removes the item at the given index and returns it. So you are on the right track, but you just need to append the return value to a new list. Like: new_list = [] new_list.append(friends.pop(0)) More on reddit.com
๐ŸŒ r/learnprogramming
3
1
September 22, 2021
๐ŸŒ
Narkive
python-ideas.python.narkive.com โ€บ sayXvTei โ€บ pop-multiple-elements-of-a-list-at-once
pop multiple elements of a list at once
It is true that to pop off a whole slice there is a more efficient way than calling pop() repeatedly -- but there's no need for a new primitive operation, as it can already be done by copying and then deleting the slice (again, the copying only copies the pointers). Try reading up on Python's memory model for objects, it will be quite enlightening. ... Post by Guido van Rossum I think yo misunderstand the implementation of lists (and the underlying malloc()).
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ pop multiple elements python
Pop multiple elements Python
July 24, 2023 - Note: The pop() method is used to remove and return a single element from a list based on its index. Simple example code. ... my_list = [1, 2, 3, 4, 5, 6] indices_to_remove = [1, 3] # Sort the indices in descending order to avoid index errors ...
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Pop Multiple Items from a List in Python - YouTube
Learn how to efficiently `pop multiple items` from a list in Python without encountering index errors.---This video is based on the question https://stackove...
Published ย  March 26, 2025
Views ย  6
๐ŸŒ
Iditect
iditect.com โ€บ faq โ€บ python โ€บ pop-multiple-items-from-the-beginning-and-end-of-a-list-in-python.html
Pop multiple items from the beginning and end of a list in python
Description: This query seeks a method to remove multiple elements from the start of a Python list. # Code to pop multiple items from the beginning of a list def pop_multiple_from_beginning(lst, count): return lst[count:], lst[:count] my_list = [1, 2, 3, 4, 5] popped_items, remaining_items = pop_multiple_from_beginning(my_list, 2) print("Popped items:", popped_items) # Output: [1, 2] print("Remaining items:", remaining_items) # Output: [3, 4, 5]
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_list_pop.asp
Python List pop() Method
Remove List Duplicates Reverse ... Plan Python Interview Q&A Python Bootcamp Python Training ... The pop() method removes the element at the specified position....
Find elsewhere
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ python pop() function | first, by value, pop multiple examples
Python pop() Function | First, by value, pop multiple Examples - EyeHunts
July 28, 2021 - languages = ['Python', 'Java', 'C++', 'Kotlin'] # Negative value print(languages.pop(-1)) print(languages) Answer: To remove the first element from a list, just pass the index value 0 into a pop function. list1 = [1, 4, 3, 6, 7] # Remove first value print(list1.pop(0)) print(list1) ... list1 = [1, 4, 3, 6, 7] # Remove indices = {0, 2} print([v for i, v in enumerate(list1) if i not in indices])
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ the most pythonic way to remove multiple items from a list
The Most Pythonic Way to Remove Multiple Items From a List - Be on the Right Side of Change
June 26, 2020 - The list.pop() method removes and returns the last element from an existing list. The list.pop(index) method with the optional argument index removes and returns the element at the position index. indices = [0, 2, 5] # must be ordered! shift = 0 for i in indices: todo_list.pop(i-shift) shift ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ why pop method removes two list at once?
r/learnpython on Reddit: Why pop method removes two list at once?
December 17, 2023 -

I'm doing the Python Crash Course and I got to this exercise, and I was wondering why the pop method is removing two list of my guest.

guest = ['aaron', 'john', 'pedro', 'kevin', 'mark', 'brad'] 
print(guest) 
guest.pop() 
print(f"{guest.pop()}") 
print(guest)

Output:
['aaron', 'john', 'pedro', 'kevin', 'mark', 'brad'] 
mark 
['aaron', 'john', 'pedro', 'kevin']

I tried assigning it with variable now it works. How is it different from the first though?

guest = ['aaron', 'john', 'pedro', 'kevin', 'mark', 'brad'] 
print(guest) 
guest_1 = guest.pop() 
print(f"{guest_1}") 
print(guest)

Output:
['aaron', 'john', 'pedro', 'kevin', 'mark', 'brad'] 
brad 
['aaron', 'john', 'pedro', 'kevin', 'mark']

๐ŸŒ
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 ... type in the Python programming language. ... The list.pop() method removes and returns the last element from an existing list....
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-list-pop-how-to-pop-an-element-from-a-array
Python list.pop() โ€“ How to Pop an Element from a Array
February 9, 2023 - In this article, you'll learn how to remove elements in a Python list using: The pop() method.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ how do i add multiple things to a pop list in python?
r/learnprogramming on Reddit: How do I add multiple things to a pop list in Python?
September 22, 2021 -

I'm working on a project where I have to invite a bunch of people to a party yadda yadda yadda. Long story short I have to pop a bunch of names from my list. I want to add them to a new list because they are no longer invited (I know, I'm an asshole). Then use that list to send out a cancellation notice. I'm able to pop one name successfully and add it to "popped_names" but I don't quite know how to add more people to "popped_friends." Or does pop just not work that way? Here is a snippet of the code I'm working with. Mainly the "problem" part, everything else I think is kind of useless:

popped_friends = friends.pop(0)

friends.append('Kara')
friends.insert(3 , 'Anna')
friends.insert(0, 'Candace')

for name in friends:
	print("Hi", name.title(), 'would you like to come over for dinner? I found a bigger table!')

print('\nHey sorry guys. The bigger table wont be here on time so I can only invite 2 people. Sorry!')
popped_friends = friends.pop(0)
popped_friends = friends.pop(2)
popped_friends = friends.pop(2)

print(popped_friends)
for name in popped_friends:
	print("Sorry" , name.title(), "I don't have room at the table anymore")

The problem in particular is towards the end after I tell everyone I can only invite a few people. The reason I'm asking is because that loop at the end outputs this:

Sorry A I don't have room at the table anymore
Sorry N I don't have room at the table anymore
Sorry N I don't have room at the table anymore
Sorry A I don't have room at the table anymore

Which leads me to believe that "Anna" is the only person in the list because.

Does pop even work this way? Or am I crazy?

๐ŸŒ
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.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ list โ€บ pop
Python List pop()
# remove and return the 4th item return_value = languages.pop(3) print('Return Value:', return_value) # Updated List print('Updated List:', languages) ... Note: Index in Python starts from 0, not 1.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ pop()
Python Pop Method: Essential Data Manipulation techniques
Master Python from basics to advanced topics, including data structures, functions, classes, and error handling ... Start your coding journey with Python. Learn basics, data types, control flow, and more ... This method modifies the original list in-place. ... fruits = ['apple', 'banana', 'cherry', 'date'] # 1. Pop the last item (no index provided) last_fruit = fruits.pop() print(f"Popped item: {last_fruit}") # Outputs: Popped item: date print(f"List is now: {fruits}") # Outputs: List is now: ['apple', 'banana', 'cherry'] # 2.
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']
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-list-pop-method
Python List pop() Method - GeeksforGeeks
October 24, 2024 - If we don't pass any argument to the pop() method, it removes the last item from the list because the default value of the index is -1. ... After using pop(), the list a is updated to [10, 20, 30]. The pop() method will raise an IndexError if ...