My answer is not exactly to your question but after you read this, I hope you can decide which type you need to choose for your needs.

Python’s lists are variable-length arrays, not Lisp-style linked lists. The implementation uses a contiguous array of references to other objects, and keeps a pointer to this array.

This makes indexing a list a[i] an operation whose cost is independent of the size of the list or the value of the index.

When items are appended or inserted, the array of references is resized. Some algorithm is applied to improve the performance of appending items repeatedly; when the array must be grown, some extra space is allocated so the next few times don’t require an actual resize i.e over-allocation. More Information

Removing vs Pop vs Delete:

At first glance it looks like all of them are doing the same thing.

Under the hood its behaving different.

removing : remove an element from the list by iterating from 0 index till the first match of the element is found. taking more time to iterate if the element is at the end.

pop : removing element from the list by using the index. taking less time.

del : is a python statement that removes a name from a namespace, or an item from a dictionary, or an item from a list by using the index.

REMOVE:

  • it removes the first occurence of value.
  • raises ValueError if the value is not present.
  • it takes only one argument, so you can't remove multiple value in one shot.

POP:

  • remove and return item at index (default last).
  • Raises IndexError if list is empty or index is out of range.
  • it takes only one argument, so you can't remove multiple value in one shot.

DEL:

  • remove the item at index and return nothing.
  • it can remove slices from a list or can clear the whole list.

Benchmark:

Worst case : deleting from the end of the list.

yopy:-> python -m timeit "x=range(1000)" "x.pop(999)"
100000 loops, best of 3: 10 usec per loop
yopy:-> python -m timeit "x=range(1000)" "x.remove(999)"
10000 loops, best of 3: 31.3 usec per loop
yopy:-> python -m timeit "x=range(1000)" "del x[999]"
100000 loops, best of 3: 9.86 usec per loop
yopy:->

Best case: begining of the list.

yopy:-> python -m timeit "x=range(1000)" "x.remove(1)"
100000 loops, best of 3: 10.3 usec per loop
yopy:-> python -m timeit "x=range(1000)" "x.pop(1)"
100000 loops, best of 3: 10.4 usec per loop
yopy:-> python -m timeit "x=range(1000)" "del x[1]"
100000 loops, best of 3: 10.4 usec per loop
yopy:->

Point to be noted:

if array grows or shrinks in the middle

  • Realloc still depends on total length.
  • But, All the trailing elements have to be copied

So, now I hope you can decide what you need to choose for your needs.

Answer from James Sapam on Stack Overflow
Top answer
1 of 4
62

My answer is not exactly to your question but after you read this, I hope you can decide which type you need to choose for your needs.

Python’s lists are variable-length arrays, not Lisp-style linked lists. The implementation uses a contiguous array of references to other objects, and keeps a pointer to this array.

This makes indexing a list a[i] an operation whose cost is independent of the size of the list or the value of the index.

When items are appended or inserted, the array of references is resized. Some algorithm is applied to improve the performance of appending items repeatedly; when the array must be grown, some extra space is allocated so the next few times don’t require an actual resize i.e over-allocation. More Information

Removing vs Pop vs Delete:

At first glance it looks like all of them are doing the same thing.

Under the hood its behaving different.

removing : remove an element from the list by iterating from 0 index till the first match of the element is found. taking more time to iterate if the element is at the end.

pop : removing element from the list by using the index. taking less time.

del : is a python statement that removes a name from a namespace, or an item from a dictionary, or an item from a list by using the index.

REMOVE:

  • it removes the first occurence of value.
  • raises ValueError if the value is not present.
  • it takes only one argument, so you can't remove multiple value in one shot.

POP:

  • remove and return item at index (default last).
  • Raises IndexError if list is empty or index is out of range.
  • it takes only one argument, so you can't remove multiple value in one shot.

DEL:

  • remove the item at index and return nothing.
  • it can remove slices from a list or can clear the whole list.

Benchmark:

Worst case : deleting from the end of the list.

yopy:-> python -m timeit "x=range(1000)" "x.pop(999)"
100000 loops, best of 3: 10 usec per loop
yopy:-> python -m timeit "x=range(1000)" "x.remove(999)"
10000 loops, best of 3: 31.3 usec per loop
yopy:-> python -m timeit "x=range(1000)" "del x[999]"
100000 loops, best of 3: 9.86 usec per loop
yopy:->

Best case: begining of the list.

yopy:-> python -m timeit "x=range(1000)" "x.remove(1)"
100000 loops, best of 3: 10.3 usec per loop
yopy:-> python -m timeit "x=range(1000)" "x.pop(1)"
100000 loops, best of 3: 10.4 usec per loop
yopy:-> python -m timeit "x=range(1000)" "del x[1]"
100000 loops, best of 3: 10.4 usec per loop
yopy:->

Point to be noted:

if array grows or shrinks in the middle

  • Realloc still depends on total length.
  • But, All the trailing elements have to be copied

So, now I hope you can decide what you need to choose for your needs.

2 of 4
39

Use a list comprehension:

Scenario 1:

[item for item in my_list if 1 <= item <=5 ]

Scenario 2:

to_be_removed = {'a', '1', 2}
[item for item in my_list if item not in to_be_removed ]

Scenario 3:

[item for item in my_list if some_condition()]

Scenario 4(Nested list comprehension):

[[item for item in seq if some_condition] for seq in my_list]

Note that if you want to remove just one item then list.remove, list.pop and del are definitely going to be very fast, but using these methods while iterating over the the list can result in unexpected output.

Related: Loop “Forgets” to Remove Some Items

🌐
W3Schools
w3schools.com › python › python_lists_remove.asp
Python - Remove List Items
Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary · Built-in Modules Random Module Requests Module Statistics Module Math Module cMath Module · Remove List Duplicates Reverse a String Add Two Numbers
Discussions

python - How to remove an element from a list by index - Stack Overflow
How do I remove an element from a list by index? I found list.remove(), but this slowly scans the list for an item by value. More on stackoverflow.com
🌐 stackoverflow.com
Removing a specific element from a list
lst.index(thing) will get you the index of the first occurrence of thing in lst (it will raise an error if it's not in list, so be aware that you have to handle that). lst.pop(index) will remove whatever is at index. If your first list could possibly have duplicates, you'll have to be careful with your current method (though it's still pretty close). Also note, you don't need is in, just in More on reddit.com
🌐 r/learnpython
7
3
January 23, 2021
[Question] Removing objects from a list while iterating over it
Try to iterate over a copy of the original list: for i in lst[:]: if i == 2: lst.remove(i) You can also do that without a for loop, with list comprehension: new_lst = [i for i in lst if i != 2] Note that solution may be faster, and is considered cleaner. More on reddit.com
🌐 r/Python
26
4
November 8, 2010
Removing comma from a tuple
Have you tried googling 'python string from tuple'? Because the first result already shows the answer: ''.join(the_tuple) More on reddit.com
🌐 r/learnpython
23
2
January 8, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › python › remove-item-from-list-in-python
How to Remove Item from a List in Python - GeeksforGeeks
The list is modified in place. A slice can be used with del to remove multiple elements from a list.
Published: 3 days ago
🌐
StrataScratch
stratascratch.com › blog › how-to-remove-an-element-from-a-list-in-python
How to Remove an Element from a List in Python - StrataScratch
October 3, 2025 - In order for your solution to be accepted, your solution should be located on the last line of the editor and match the expected output data type listed in the question. ... This solution first sums the number of messages per guest, then ranks them using the dense method to avoid gaps in rank values. It uses no element removal method, but involves column reordering via .pop() and .insert(). In Python, removing items from a list is a fundamental yet crucial skill.
🌐
ReqBin
reqbin.com › code › python › niedpzpq › python-list-remove-example
How do I remove an element from a list in Python?
December 22, 2022 - To remove a specific item from a Python list, you can use the list.remove() method. If more than one element in the list matches the specified value, only the first occurrence of that element will be removed.
🌐
Analytics Vidhya
analyticsvidhya.com › home › how to remove an item from a list in python ?
How to Remove Element from list in Python?
July 22, 2024 - Q3: How do I remove an item at a specific index using Python? A3: Utilize the del statement, specifying the index of the item you want to remove. Q4: Can I remove multiple occurrences of an item in a list?
🌐
Edureka
edureka.co › blog › python-list-remove
Remove Elements From Lists | Python List remove() Method | Edureka
February 6, 2025 - Also, this is a fast method to remove items from a list.) To summarize, the remove() method removes the first matching value, and not a specified index; the pop() method removes the item at a specified index, and returns it; and finally the del operator just deletes the item at a specified index ( or a range of indices). In Python, you can delete elements from a list using several methods.
Find elsewhere
🌐
Programiz
programiz.com › python-programming › methods › list › remove
Python List remove() (with Code Visualization)
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... The remove() method removes the first matching item from a list.
🌐
SitePoint
sitepoint.com › python hub › remove list items
Python - Remove List Items | SitePoint — SitePoint
Here, we first check if the element exists in the list before attempting to remove it. The pop() method removes an element at a specified index and returns its value. ... If no index is provided, it removes and returns the last element.
🌐
DataCamp
datacamp.com › tutorial › python-remove-item-from-list
How to Remove an Item from a List in Python: A Full Guide | DataCamp
August 1, 2024 - In the first case, we can use the remove() function. # Initialize a list with integers from 1 to 5 my_list = [1, 2, 3, 4, 5] # Removes element 5 from the list my_list.remove(5) print(my_list) # Expected output: [1, 2, 3, 4]
🌐
Index.dev
index.dev › blog › remove-item-from-python-list
Python List Remove: Delete Elements from List (7 Methods + Code) | Index.dev
May 14, 2025 - Use pop() or del when you know the position: python # Python delete from list by index names = ['Alice', 'Bob', 'Charlie', 'Diana'] # Using pop() - returns the removed item removed = names.pop(2) # Removes 'Charlie' print(removed) # 'Charlie' ...
🌐
Real Python
realpython.com › remove-item-from-list-python
How to Remove Items From Lists in Python – Real Python
October 21, 2025 - Note that Python lists use zero-based indexing for positioning, which means that the first element in a list is at index 0, the second element is at index 1, and so on. With that in mind, here’s an example of how you can use .pop() to remove and display the first element in your books list: ... You invoke the .pop() method on the books list with an index of 0, indicating the first element in the list. This call removes the first title, Dragonsbane, from the list and then returns it.
🌐
freeCodeCamp
freecodecamp.org › news › python-list-remove-how-to-remove-an-item-from-a-list-in-python
Python List .remove() - How to Remove an Item from a List in Python
March 2, 2022 - To remove an element from a list using the remove() method, specify the value of that element and pass it as an argument to the method. remove() will search the list to find it and remove it.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Remove an Item from a List in Python: remove, pop, clear, del | note.nkmk.me
April 17, 2025 - In Python, you can remove items (elements) from a list using methods such as remove(), pop(), and clear(). You can also use the del statement to delete items by index or slice. Additionally, list comp ...
🌐
Reddit
reddit.com › r/learnpython › removing a specific element from a list
r/learnpython on Reddit: Removing a specific element from a list
January 23, 2021 -

I have a function that receives two lists. The goal is for the function to return lst1 without the elements on lst2, however I'm having trouble with that. What can I do?

I do have to say that I cannot use any while or for loop, only recursion (that's the hard part)

def minus(lst1,lst2):
    element = lst2.pop()
    if element is in lst1:
        #how can I find the position of the elements in lst1 that is equal to "element"?
    else:
        if len(lst2) == 0:
            return lst1
        else:
            return minus(lst1,lst2)
🌐
Great Learning
mygreatlearning.com › blog › it/software development › how to remove an item from a list in python
How to Remove an Item from a List in Python
June 11, 2025 - Using clear(): Remove all items from the list. Let’s look at each one. The remove() method takes the value of the item you want to remove.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-remove
Python List remove() Method - GeeksforGeeks
July 17, 2026 - Explanation: a.remove("banana") removes the first occurrence of "banana" from the list. The original list is updated directly. ... Parameter: element - item to remove from the list.
🌐
Educative
educative.io › answers › how-to-delete-an-element-from-a-list-in-python
How to delete an element from a list in Python
For this shot, let’s look at how we can delete a value at a certain index with the del keyword: ... The pop method removes an element at a given index and returns its value. The code below shows an example of this: ... Note: The argument passed ...
🌐
Stack Abuse
stackabuse.com › remove-element-from-an-array-in-python
How to Remove Elements from an Array/List in Python
September 15, 2023 - We can use the remove() method on any array or list in Python. To use it, we can simply pass the value of the element we want to remove. Let's imagine we have the following array: ... Another way we can remove elements from list/array in Python is by using the pop() method.