Content · Programming · Python

Python list.remove() vs list.pop() vs del

remove(value) deletes the first matching value, pop(index) removes and returns a positional element, and del deletes at a position or slice without returning it. See two practical examples, edge cases and common.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

A task manager must remove tasks by label, by position or as a range.

What You Need to Understand


remove(value) deletes the first matching value, pop(index) removes and returns a positional element, and del deletes at a position or slice without returning it.

When to Use It


A task manager must remove tasks by label, by position or as a range.

Step-by-Step Python Example


tasks = ["email", "review", "email", "archive"]
tasks.remove("email")
removed = tasks.pop(0)
del tasks[:1]
print(removed)
print(tasks)

How the Example Works


After removing the first email, pop(0) returns review; deleting the first remaining item leaves just archive.

Example Output


review
['archive']
[10, 30]

A Second Example


Compare this smaller variation with the main example, then experiment with your own values.

values = [10, 20, 30]
del values[1]
print(values)

Important Behavior and Edge Cases


remove() raises ValueError for absent values; pop() raises IndexError for invalid indexes; del tasks deletes the name itself.

Try It Yourself


Remove the last element by pop() and compare it with del values[-1].

Common Beginner Mistakes


  • remove() raises ValueError for absent values; pop() raises IndexError for invalid indexes; del tasks deletes the name itself.
  • Overlooking how an iterable is consumed, how element positions are chosen, or whether a function creates a new list.

Key Takeaways


  • remove(value) deletes the first matching value, pop(index) removes and returns a positional element, and del deletes at a position or slice without returning it.
  • After removing the first email, pop(0) returns review; deleting the first remaining item leaves just archive.
  • remove() raises ValueError for absent values; pop() raises IndexError for invalid indexes; del tasks deletes the name itself.
Share this resourceSend this page to someone who may find it useful.