

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove an object from a list in Python?
You can use 3 different methods to remove an object from a list in Python. They are remove, del and pop. You can use them as follows −
The remove method removes the first value matching the argument to remove from the list, not a specific index.
example
a = [3, 2, 3, 2] a.remove(3) print(a)
Output
This will give the output −
[2, 3, 2]
The del method removes a specific index from the list.
example
a = [3, "Hello", 2, 1] del a[1] print(a)
Output
This will give the output −
[3, 2, 1]
The pop method returns the removed element. The argument to pop is the index you want to remove.
Example
a = [3, "Hello", 2, 1] print(a.pop(1)) print(a)
Output
This will give the output −
"Hello" [3, 2, 1]
- Related Questions & Answers
- How to remove an element from a list in Python?
- How to remove an element from a list by index in Python?
- How to remove a function from an object in JavaScript?
- How to remove index list from another list in python?
- Python | Remove empty tuples from a list
- How to remove an element from Array List in C#?
- How to remove an item from a C# list by using an index?
- How to remove a property from a JavaScript object
- How to remove a property from a JavaScript object?
- How to remove all blank objects from an Object in JavaScript?
- Remove number properties from an object JavaScript
- Python program to remove Duplicates elements from a List?
- Python Program to Remove Palindromic Elements from a List
- Python - Ways to remove duplicates from list
- How to return an object from a function in Python?
Advertisements