🌐
W3Schools
w3schools.com › python › python_lists_remove.asp
Python - Remove List Items
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort · MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete ...
🌐
W3Schools
w3schools.com › python › ref_keyword_del.asp
Python del Keyword
In Python everything is an object, so the del keyword can also be used to delete variables, lists, or parts of a list etc. ... Coding fundamentals as a game. Bite-sized lessons and challenges. ... Ready to start your journey? Your streak is waiting. ... If you want to use W3Schools services ...
🌐
W3Schools
w3schools.com › python › trypython.asp
W3Schools online PYTHON editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
W3Schools
w3schools.com › python › gloss_python_remove_list_items.asp
Python Remove a List Item
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort · MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete ...
🌐
Programiz
programiz.com › python-programming › del
Python del Statement (With Examples)
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] # deleting the third item del my_list[2] # Output: [1, 2, 4, 5, 6, 7, 8, 9] print(my_list) # deleting items from 2nd to 4th del my_list[1:4] # Output: [1, 6, 7, 8, 9] print(my_list) # deleting all elements del my_list[:] # Output: [] print(my_list) person = { 'name': 'Sam', 'age': 25, 'profession': 'Programmer' } del person['profession'] # Output: {'name': 'Sam', 'age': 25} print(person) ... Note: You can't delete items of tuples and strings in Python.
🌐
Du
cs.du.edu › ~intropython › intro-to-programming › list_methods.html
List methods - Introduction to Programming
The full list can be found at Python list documentation by w3schools or Offical python documentation on list methods. Here are the list methods you'll learn: the count() and index() methods for counting and searching · theinsert() and extend() methods for adding elements · the pop() and remove() methods and the del keyword for removing elements
🌐
Tutorial Gateway
tutorialgateway.org › python-list-del-function
Python List del Function
March 29, 2019 - The list del function removes the value at a specified index. After deleting, the remaining values moved up to fill the index gap. If we know the Index value or want to eliminate a range of items from the given object, then use the del statement ...
🌐
W3Schools
w3schools.com › python › ref_list_remove.asp
Python List remove() Method
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort · MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete ...
🌐
W3Schools
w3schools.com › python › ref_list_clear.asp
Python List clear() Method
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort · MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete ...
Find elsewhere
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.7 documentation
There is a way to remove an item from a list given its index instead of its value: the del statement. This differs from the pop() method which returns a value. The del statement can also be used to remove slices from a list or clear the entire ...
🌐
W3Schools
w3schools.com › python › python_lists.asp
Python Lists
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort · MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete ...
🌐
GitHub
github.com › pydawan › w3schools-python-tutorial › blob › master › lists.py
w3schools-python-tutorial/lists.py at master · pydawan/w3schools-python-tutorial
del thislist · print(thislist) # this will cause an error because "thislist" no longer exists · · # The clear() method empties the list: thislist = ["apple", "banana", "cherry"] thislist.clear() print(thislist) · # The list() Constructor · # It is also possible to use the list() constructor to make a list. # note the double round-brackets · thislist = list(("apple", "banana", "cherry")) print(thislist) · # List Methods · # # Python has a set of built-in methods that you can use on lists.
Author: pydawan
🌐
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 - del is a keyword and remove(), and pop() are in-built methods in Python. The purpose of these three is the same but the behavior is different. remove() method deletes values or objects from the list using value and del and pop() deletes values ...
🌐
W3Schools
w3schools.com › python › python_lists_methods.asp
Python - List Methods
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort · MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete ...
🌐
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
July 3, 2026 - The del method is useful when deleting an item at a specific position in the list. For example: mylist = ['a', 'b', 'c', 'd'] del mylist[2] # will delete the item at index 2, that is 'c' print(mylist) # will print ['a', 'b', 'd']
🌐
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.
🌐
Python.org
discuss.python.org › python help
How to delete all the items (in a list) beautifully? - Python Help - Discussions on Python.org
February 10, 2024 - How to delete all the items (in a list) beautifully · Hello! I want to know how to delete all the items (in a list) beautifully? For example: list = [2, 3, 4] Can I just do it in this way? list = [] Or del list[2], del list[1], del list[0] Thank you for your time · For the record list.clear() ...
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

🌐
TutorialsPoint
tutorialspoint.com › How-does-del-operator-work-on-list-in-Python
How does del operator work on list in Python?
April 4, 2023 - The del operator removes an item or an element from the list at the provided index location, but the item is not returned.