The effects of the three different methods to remove an element from a list:

remove removes the first matching value, not a specific index:

>>> a = [0, 2, 3, 2]
>>> a.remove(2)
>>> a
[0, 3, 2]

del removes the item at a specific index:

>>> a = [9, 8, 7, 6]
>>> del a[1]
>>> a
[9, 7, 6]

and pop removes the item at a specific index and returns it.

>>> a = [4, 3, 5]
>>> a.pop(1)
3
>>> a
[4, 5]

Their error modes are different too:

>>> a = [4, 5, 6]
>>> a.remove(7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: list.remove(x): x not in list
>>> del a[7]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list assignment index out of range
>>> a.pop(7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: pop index out of range
Answer from Martijn Pieters on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-is-difference-between-del-remove-and-pop-on-python-lists
Difference Between Del, Remove and Pop in Python Lists - GeeksforGeeks
July 23, 2025 - remove() method deletes values or objects from the list using value and del and pop() deletes values or objects from the list using an index. del is a Python Keyword that is used to delete items from a list by index or to remove the entire list.
Discussions

Difference between del and .remove()? should one be preferred over the other? if so why?
fahad lashari is having issues with: Just want to know if I should be using one over the other as they both achieve the same result More on teamtreehouse.com
🌐 teamtreehouse.com
2
November 26, 2016
Do You Ever del?
I used to use del to remove keys from dicts, but nowadays I mostly prefer .pop(), since I can avoid using a try...catch by adding a default value. The only situation I use del nowadays is when freeing an object in PyQt, because freeing C++ data bound in python is arcane stuff: import PyQt6 widget = PyQt6.QWidgets.QWidget() ... widget.setParent(None) widget.deleteLater() del widget Crazy stuff. And you better not have passed that `widget` reference anywhere, otherwise the garbage collector will fuck your day up. More on reddit.com
🌐 r/Python
112
193
December 31, 2023
python - What is the difference between `__del__` and `__delete__`? - Stack Overflow
Sometimes a person has 6 or 7 names tags on simultaneously, and other times, they only have one. Python will kick anyone out of the party who is not wearing at least one name tag. MyClass.__del__(my_instance) gets called when the last name-tag/label is removed from a piece of data. More on stackoverflow.com
🌐 stackoverflow.com
how is del(item) different from list.remove(item) in python list - Stack Overflow
I wanted to delete words from a list having length greater than 3. I used del (item) but it didn't worked. Here is the code: lst=['XDA-OT','hi','loc','yeah'] for i in lst: if len(i)>3: ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/learnpython › del or remove to delete an item from a list
r/learnpython on Reddit: del or remove to delete an item from a list
May 24, 2018 -

Hi, I'm currently learning Python using, among others, automatetheboringstuff.com
It's a great resource, and I enjoy hacking through the projects.

I am now finishing Chapter 8 (https://automatetheboringstuff.com/chapter8/), and I'm doing the first project, "Create the Quiz File and Shuffle the Question Order".

In that project, at one point, we need to remove an item from a list. Said item's value is stored in a variable. I decided to use the .remove command, like this:

my_list = ['cat', 'dog', 'duck', 'rabbit']
item_to_be_removed = 'dog'        

my_list.remove(item_to_be_removed)

But the author uses instead the "del" command, such as:

del my_list[my_list.index(item_to_be_removed)]    

My question: is there a difference ? It seems much easier to use the first method. I understand that "del" will delete an item using it's index number, and "remove" will remove the first instance of the value we want to delete. But in the context of the project, I don't see why del was chosen.

(Both "del" and ".remove" were explained in previous chapters of the book)

🌐
Sentry
sentry.io › sentry answers › python › removing items from python lists: `del` vs `pop` vs `remove`
Removing items from Python lists: `del` vs `pop` vs `remove` | Sentry
3 weeks ago - While these three methods remove an item from a list, they all work differently. The del method is useful when deleting an item at a specific position in the list.
🌐
TutorialsPoint
tutorialspoint.com › article › difference-between-del-and-remove-on-lists-in-python
Difference Between Del and Remove() on Lists in Python?
March 26, 2026 - Original List = [1, 2, 3, 2, 4, 2] After remove(2) = [1, 3, 2, 4, 2] Use del when you know the exact index position or want to delete multiple elements.
Top answer
1 of 2
3
It depends on the context. If you only know what the element is and not it's index, you should user .remove(). If you only know the index on the other hand and not what the element is, you should use del. Usually, you don't know both, but if you know both the index and what the element's value, I'd still use .remove(), since to me it makes more since. But, if there is a chance that there's two elements that contain the same value, you should probably use del instead (because .remove() removes the first element with the value). I hope you understand. :) Good luck! ~Alex
2 of 2
5
It might have already been explained elsewhere, but the simple difference between del and .remove() is that del removes one specific thing in one specific place, and .remove() will just automatically remove the first instance of that thing. For example, I can say del grocery_list[3] and it will automatically delete the 4th thing in my grocery list (remember: lists begin counting at 0). Even if the third and fourth thing on my grocery list are the same, the fourth one will get deleted, because I specified exactly where in my list I wanted something to be deleted. If I had used grocery_list.remove('carrots'), it would automatically remove the first instance of 'carrots' from my grocery list. Even if the third and fourth items are both called 'carrots,' the third item will get deleted, because it's the first appearance of that item in my list. If you know what your list looks like, and you know which index you want to delete, the del keyword is preferred. If you just want to remove something from your list, and you don't know where it is. Use .remove() instead. Basically, del works by specifying an item's location with an index, and .remove() works by passing in an argument (e.g. string, int, float, etc.).
Find elsewhere
🌐
Real Python
realpython.com › python-del-statement
Python's del: Remove References From Scopes and Containers – Real Python
October 21, 2023 - Now get back to your factorial.py file and comment out line 8, which contains the del statement that removes ._cache. With this change in place, go ahead and run the above function call again: ... Now the size of your Factorial instance is more than 23 times greater than before. That’s the impact of removing vs keeping the unnecessary cached data once the instance is complete. ... In Python, you can write your classes in a way that prevents the removal of instance attributes.
🌐
TechGeekBuzz
techgeekbuzz.com › blog › difference-between-del-remove-and-pop-on-python-lists
Difference Between Del, Remove, Clear and Pop on Python Lists
Let us discuss each method and the del keyword in detail below with examples. The del is a reserved word in Python to delete objects. As everything in Python is an object, the del keyword deletes variables, lists, or items of a list.
🌐
Medium
allwin-raju.medium.com › understanding-pop-remove-and-del-in-python-abb9e0223706
Understanding pop, remove, and del in Python | by Allwin Raju | Medium
December 1, 2024 - Understanding pop, remove, and del in Python Python provides several ways to remove elements from data structures, each with unique functionality and use cases. Among these, pop(), remove(), and del …
🌐
CSEstack
csestack.org › home › difference between remove del and pop in python list
Difference Between remove del and pop in Python List
July 12, 2021 - You can also check other Python tutorial. This might help you with your preparation. ... Also, del can be used to delete the entire list whereas pop can only be used to delete element at a specific index.
🌐
Codecademy
codecademy.com › forum_questions › 5392c30c8c1ccc9774000539
What's the difference between del and .remove() ? | Codecademy
.remove(defined value) - will look at the index and remove the first instance of a defined value del - by comparison will look at the index and delete a specific value defined by it’s position in the index
🌐
Dot Net Perls
dotnetperls.com › del-python
Python - del Operator - Dot Net Perls
On lists, we can remove slices (ranges of elements) at once. Here we call del to remove the third element in a list.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-__delete__-vs-__del__
Python : __delete__ vs __del__ - GeeksforGeeks
July 12, 2025 - __delete__ is used to delete the attribute of an instance i.e removing the value of attribute present in the owner class for an instance. Note: This method only deletes the attribute which is a descriptor.
🌐
Programiz
programiz.com › python-programming › del
Python del Statement (With Examples)
The del statement can be used to delete an item at a given index. It can also be used to remove slices from a list.
🌐
Edureka
edureka.co › blog › python-list-remove
Remove Elements From Lists | Python List remove() Method | Edureka
February 6, 2025 - 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 ( ...
Top answer
1 of 2
3

object.__del__(self):

Called when the instance is about to be destroyed. This is also called a finalizer or (improperly) a destructor. If a base class has a __del__() method, the derived class’s __del__() method, if any, must explicitly call it to ensure proper deletion of the base class part of the instance.

This means that my_object.__del__ will get called by CPython's garbage collector after the reference count for my_object drops to zero.

object.__delete__(self, instance):

Called to delete the attribute on an instance instance of the owner class.

The __delete__ dunder method is related to python's notion of descriptors; a descriptor is "any object which defines the methods __get__(), __set__(), or __delete__()." Descriptors can be used to implement custom behavior for attribute lookup/assignment/deletion (via __get__/__set__/__delete__, respectively). If MyClass has a class variable x that has a __delete__ method then instance = MyClass(); del instance.x will cause x.__delete__ to be called:

class X:
    def __delete__(self, instance):
        print("custom delete method")

class MyClass:
    x = X()

instance = MyClass()
del instance.x  # prints "custom delete method"
del instance.x  # prints "custom delete method" again

See the descriptor guide.

See also:

  • The del statement: "Deletion of a name removes the binding of that name from the local or global namespace... Deletion of attribute references, subscriptions and slicings is passed to the primary object involved..."
  • The delattr built-in function. From the docs, "The function deletes the named attribute, provided the object allows it. For example, delattr(x, 'foobar') is equivalent to del x.foobar."
  • object.__delattr__(self, name) is called when attribute deletion is attempted. According to the docs, "This should only be implemented if del obj.name is meaningful for the object." Thus, defining a user class with the method MyClass.__delattr__ enables custom behavior when e.g. the statement del my_object.an_attr is invoked, or (equivalently) when delattr(my_object, 'an_attr') is called.
  • object.__delitem__(self, key) is "Called to implement deletion of self[key]." Thus, defining a user class with the method MyClass.__delitem__ enables custom behavior when e.g. the statement del my_object[a_key] is invoked.
2 of 2
-2

__del__ is called when you delete an object and __delete__ is sometimes called when you delete an attribute of an object.

del x.my_num    # __delete__
del x           # __del__            

ABOUT __del__:

The following code shows when __del__ gets called:

class MyClass:
    def __init__(self):
        file = open("really_cool_file.txt", "w+")
        self._f = file

    def __del__(self):
        print("closing any open files ")
        self._f.close()

my_instance = MyClass()
del my_instance

If my_instance is the last label pointing to the data, then del my_instance calls MyClass.__del__(my_instance)

Technically, del my_instance only deletes the label my_instance. Imagine people at a party all wearing names tags. Sometimes a person has 6 or 7 names tags on simultaneously, and other times, they only have one. Python will kick anyone out of the party who is not wearing at least one name tag. MyClass.__del__(my_instance) gets called when the last name-tag/label is removed from a piece of data.

The code above shows an example of when we make sure to close an open file. Another example might be to count of the number active instances of a given class:

class Klass:
    count = 0
    # `count` belongs to the class
    # instances do not each get their own copy of `count`
    def __init__(self):
        type(self).count += 1
        self.instance_var = "I belong to instances"
    def __del__(self):
        type(self).count -= 1
obj = Klass()
print(obj.count)

ABOUT __delete__

Unlike __del__, __delete__ has to do with descriptors. The code below describes the behavior of obj.my_var or getattr(obj, “my_var”)

class Klaus: def getattribute(self, attrname): try: attribute = attrname from instance Klaus except AttributeError: attribute = attrname from class Klaus

    # Begin code for handling "descriptors"
    if hasattr(attribute, '__get__'):
        attr = attribute.__get__(self, Klaus)
    # End code for handling "descriptors"

    return attribute

If my_var is a descriptor, then following two lines of code equivalent:

x = obj.my_var
x = Klass.my_var.__get__(obj, "my_var")

Just as __getattribute__ checks whether the attribute has a __get__ method or not, __delattr__ will check whether the attribute has a __delete__ method or not.

def __delattr__(self, name):
    attribute = getattr(self, name)
    if hasattr(attribute, "__delete__"):
       attribute.__delete__(self)
    else:
       del self.__dict__[name]

You can see when __delete__ gets called by viewing the following code:

class desc:
    def __delete__(descriptor, instance_of_Klaus):
        print("attribute was deleted")

class Klaus:
    d = desc()
    def __init__(self):
        pass

my_instance = Klaus()
del my_instance.d

When dealing with descriptors, the following lines of code are all equivalent:

del my_instance.d
delattr(my_instance, "d")
Klaus.d.__delete__(my_instance)
🌐
Quora
quora.com › In-Python-whats-the-difference-between-pop-del-and-remove-on-lists
In Python, what's the difference between pop, del and remove on lists? - Quora
Answer (1 of 8): The remove operation on a list is given a value to remove. It searches the list to find an item with that value and deletes the first matching item it finds. It is an error if there is no matching item. 5. Data Structures The del statement can be used to delete an entire list. I...