October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Remove an Element from a List by Index in Python

Remove a Python list item by position with pop(index) or del list[index)—and choose based on whether you need the removed value.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use my_list.pop(index) to remove an item by its position and keep the removed value, or del my_list[index] to delete it without returning a value. Python list indexes start at 0, so index 0 means the first item.

Remove an item by index with pop() or del

For example, these two forms both remove "banana" from the list, but only pop() gives you the removed item:

items = ["apple", "banana", "cherry"]
removed = items.pop(1)

# items is ["apple", "cherry"]
# removed is "banana"
items = ["apple", "banana", "cherry"]
del items[1]

# items is ["apple", "cherry"]

The Python tutorial documents both approaches: Python 3.14.8: Data Structures.

Choose the operation that matches your goal

Operation What it does Use it when
my_list.pop(i) Removes and returns the item at index i. You need the removed item as well as the shorter list.
del my_list[i] Deletes the item at index i without returning it. You only need to change the list. del is a Python statement, not a list method.
my_list.remove(value) Searches for the first item equal to value and removes it. The target is specified by its value, not its position. It raises ValueError if no matching item exists.

For example, items.remove("banana") searches by value; it does not mean “remove the item at index 1.”

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand indexes and invalid positions

Indexes begin at zero: index 0 is the first item and index 1 is the second. A negative index counts from the end. Calling items.pop() without an argument removes and returns the last item.

pop raises IndexError if the list is empty or the index is outside the valid range. If an invalid index is an expected condition in your program, handle that case explicitly; otherwise, validating the position or letting the exception reveal a bug may be more appropriate.

Remove items at several indexes

Each deletion changes the positions of items that follow it. If you need to remove several known indexes from the same list, remove them in descending order so deleting a lower position does not shift the higher positions you still intend to delete:

items = ["a", "b", "c", "d"]
indexes = [1, 3]

for index in sorted(indexes, reverse=True):
    del items[index]

# items is ["a", "c"]

If the items to remove are defined by a condition rather than by fixed positions, building a new list with a filter is often clearer than repeatedly deleting indexes.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What repeated indexed deletion costs

Deleting an item near the beginning of a list may require shifting later items. The CPython built-in types complexity reference gives indexed pop and item deletion a cost of O(n – k), where n is the current list size and k is the index: CPython built-in types time complexity reference. For a single ordinary deletion, pop or del is the straightforward choice; if your program frequently adds or removes items at both ends, the reference recommends considering collections.deque.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.