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
๐ŸŒ
Narkive
python-ideas.python.narkive.com โ€บ sayXvTei โ€บ pop-multiple-elements-of-a-list-at-once
pop multiple elements of a list at once
Post by Diego Jacobi The thing i found is that, to pop a variable chunk of data from this buffer without copying it and deleting the elements, i have to pop one element at the time. In CPython, popping copies a reference and them deletes it from the list. The item popped is not copied.
๐ŸŒ
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
๐ŸŒ
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
๐ŸŒ
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']

Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_list_pop.asp
Python List pop() Method
Remove List Duplicates Reverse ... Python Study Plan Python Interview Q&A Python Training ... The pop() method removes the element at the specified position....
๐ŸŒ
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 ...
๐ŸŒ
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....
๐ŸŒ
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.
๐ŸŒ
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 - Python pop function is used to remove a returns last object from the list. You can also remove the element at the specified position using the pop() function by passing the index value. Note: If the index is not given, then the last element is popped out and removed from the 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 - Python has various built-in methods you can use to interact with elements stored in a list. These methods let you add, access, modify, and remove elements. In this article, you'll learn how to remove elements in a Python list using: The pop() metho...
๐ŸŒ
DEV Community
dev.to โ€บ ahf90 โ€บ atomically-popping-multiple-items-from-a-redis-list-in-python-2afa
Atomically popping multiple items from a Redis list in Python - DEV Community
October 20, 2020 - Since nobody actually uses CLIs, let's do this in Python. This script uses redis-py's Pipeline feature. Pipelines are a subclass of the base Redis class that provide support for buffering multiple commands to the server in a single request. >>> import redis >>> my_key = 'pop_trim_test' >>> r = redis.Redis(host='localhost', port=6379) >>> r.rpush(my_key, *[x for x in range(10)]) >>> pipe = r.pipeline() >>> pipe.lrange(my_key, 0, 3) >>> pipe.ltrim(my_key, 4, -1) >>> pipe.execute() [[b'0', b'1', b'2', b'3'], True]
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ remove-multiple-elements-from-a-list-in-python
Remove Multiple Elements from List in Python - GeeksforGeeks
Removing multiple elements means eliminating all occurrences of these elements and returning a new list with the remaining numbers.
Published: October 28, 2025
๐ŸŒ
CSDN
devpress.csdn.net โ€บ python โ€บ 630452b87e66823466199cc1.html
Pop multiple items from the beginning and end of a list_python_Mangs-Python
August 23, 2022 - I want to pop two items from the left (i.e. a and b) and two items from the right (i.e. h,i). I want the most concise an clean way to do this. I could do it this way myself: ... they are around 3 times faster than the first solution for _ in range(2): mylist.pop(0); mylist.pop() ... 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
๐ŸŒ
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?

๐ŸŒ
Google Groups
groups.google.com โ€บ g โ€บ python-ideas โ€บ c โ€บ 7_lxKSCoT7s
[Python-ideas] 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.